home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / doc / bsdsocket.doc < prev    next >
Text File  |  1994-04-26  |  122KB  |  3,028 lines

  1. TABLE OF CONTENTS
  2.  
  3. bsdsocket.library/accept
  4. bsdsocket.library/bind
  5. bsdsocket.library/CloseSocket
  6. bsdsocket.library/connect
  7. bsdsocket.library/Dup2Socket
  8. bsdsocket.library/Errno
  9. bsdsocket.library/getdtablesize
  10. bsdsocket.library/gethostbyaddr
  11. bsdsocket.library/gethostbyname
  12. bsdsocket.library/gethostid
  13. bsdsocket.library/gethostname
  14. bsdsocket.library/getnetbyaddr
  15. bsdsocket.library/getnetbyname
  16. bsdsocket.library/getpeername
  17. bsdsocket.library/getprotobyname
  18. bsdsocket.library/getprotobynumber
  19. bsdsocket.library/getservbyname
  20. bsdsocket.library/getservbyport
  21. bsdsocket.library/getsockname
  22. bsdsocket.library/getsockopt
  23. bsdsocket.library/inet_addr
  24. bsdsocket.library/Inet_LnaOf
  25. bsdsocket.library/inet_MakeAddr
  26. bsdsocket.library/Inet_NetOf
  27. bsdsocket.library/inet_network
  28. bsdsocket.library/Inet_NtoA
  29. bsdsocket.library/IoctlSocket
  30. bsdsocket.library/listen
  31. bsdsocket.library/ObtainSocket
  32. bsdsocket.library/recv
  33. bsdsocket.library/recvfrom
  34. bsdsocket.library/ReleaseCopyOfSocket
  35. bsdsocket.library/ReleaseSocket
  36. bsdsocket.library/select
  37. bsdsocket.library/send
  38. bsdsocket.library/sendto
  39. bsdsocket.library/SetErrnoPtr
  40. bsdsocket.library/SetSocketSignals
  41. bsdsocket.library/inet_lnaof
  42. bsdsocket.library/inet_makeaddr
  43. bsdsocket.library/inet_netof
  44. bsdsocket.library/inet_ntoa
  45. bsdsocket.library/setsockopt
  46. bsdsocket.library/shutdown
  47. bsdsocket.library/socket
  48. bsdsocket.library/SocketBaseTagList
  49. bsdsocket.library/syslog
  50. protocols/arp
  51. protocols/icmp
  52. protocols/if
  53. protocols/inet
  54. protocols/ip
  55. protocols/lo
  56. protocols/routing
  57. protocols/tcp
  58. protocols/udp
  59. bsdsocket.library/accept                             bsdsocket.library/accept
  60.  
  61.    NAME
  62.         accept - accept a connection on a socket
  63.  
  64.    SYNOPSIS
  65.         #include <sys/types.h>
  66.         #include <sys/socket.h>
  67.  
  68.         ns = accept(s, addr, addrlen)
  69.         D0          D0 A0    A1
  70.  
  71.         long accept(long, struct sockaddr *, long *);
  72.  
  73.    FUNCTION
  74.  
  75.         The  argument  s  is a  socket  that  has  been created with
  76.         socket(), bound to an  address  with bind(), and  is listen-
  77.         ing for connections after a listen().  accept() extracts the
  78.         first  connection  on  the  queue  of  pending  connections,
  79.         creates a new socket with the same properties of s and allo-
  80.         cates a new socket descriptor for the socket.  If no pending
  81.         connections are present on the  queue, and the socket is not
  82.         marked  as non-blocking, accept() blocks the caller  until a
  83.         connection is present.  If the socket is marked non-blocking
  84.         and  no  pending  connections  are  present  on  the  queue,
  85.         accept() returns  an error as described below.  The accepted
  86.         socket is used to read and write data to and from the socket
  87.         which connected to  this one; it is not used to  accept more
  88.         connections.  The original socket s remains open for accept-
  89.         ing further connections.
  90.  
  91.         The argument addr is a result parameter that  is  filled  in
  92.         with  the  address of the connecting entity, as known to the
  93.         communications layer.  The exact format of the addr  parame-
  94.         ter  is  determined by the domain in which the communication
  95.         is occurring.  The addrlen is a value-result  parameter;  it
  96.         should  initially  contain the amount of space pointed to by
  97.         addr; on return it will contain the actual length (in bytes)
  98.         of   the   address   returned.    This  call  is  used  with
  99.         connection-based socket types, currently with SOCK_STREAM.
  100.  
  101.         It is possible to select() a socket  for  the  purposes  of
  102.         doing an accept() by selecting it for read.
  103.  
  104.    RETURN VALUES
  105.         accept() returns a non-negative descriptor for the  accepted
  106.         socket on success.  On failure, it returns -1 and sets errno
  107.         to indicate the error.
  108.  
  109.    ERRORS
  110.         EBADF        - The descriptor is invalid.
  111.  
  112.         EINTR        - The operation was interrupted by a break 
  113.                        signal.
  114.  
  115.         EOPNOTSUPP   - The referenced socket is not of type
  116.                        SOCK_STREAM.
  117.  
  118.         EWOULDBLOCK  - The socket is marked non-blocking and no con-
  119.                        nections are present to be accepted.
  120.  
  121.    SEE ALSO
  122.         bind(), connect(), listen(), select(), SetSocketSignals(),
  123.         socket()
  124. bsdsocket.library/bind                                 bsdsocket.library/bind
  125.  
  126.    NAME
  127.         bind - bind a name to a socket
  128.  
  129.    SYNOPSIS
  130.         #include <sys/types.h>
  131.         #include <sys/socket.h>
  132.  
  133.         success = bind(s, name, namelen)
  134.         D0             D0 A0    D1
  135.  
  136.         long bind(long, struct sockaddr *, long);
  137.  
  138.    FUNCTION
  139.         bind() assigns a name to an unnamed socket.  When  a  socket
  140.         is created with socket(2) it exists in a name space (address
  141.         family) but has no name assigned.  bind() requests that  the
  142.         name pointed to by name be assigned to the socket.
  143.  
  144.    RETURN VALUES
  145.         0  - on success.
  146.  
  147.         -1 - on failure and sets errno to indicate the error.
  148.  
  149.    ERRORS
  150.         EACCES            - The requested address is protected,  and
  151.                             the  current user has inadequate permis-
  152.                             sion to access it.
  153.  
  154.         EADDRINUSE        - The specified address is already in use.
  155.  
  156.         EADDRNOTAVAIL     - The specified address is  not  available
  157.                             from the local machine.
  158.  
  159.         EBADF             - s is not a valid descriptor.
  160.  
  161.         EINVAL            - namelen is  not  the  size  of  a  valid
  162.                             address  for  the specified address fam-
  163.                             ily.
  164.  
  165.                             The  socket  is  already  bound  to   an
  166.                             address.
  167.  
  168.    SEE ALSO
  169.         connect(), getsockname(), listen(), socket()
  170.  
  171.    NOTES
  172.         The rules used in name binding  vary  between  communication
  173.         domains.
  174. bsdsocket.library/CloseSocket                   bsdsocket.library/CloseSocket
  175.  
  176.    NAME
  177.         CloseSocket - delete a socket descriptor
  178.  
  179.    SYNOPSIS
  180.         success = CloseSocket(s)
  181.         D0                    D0
  182.  
  183.         long CloseSocket(long);
  184.  
  185.    FUNCTION 
  186.         CloseSocket() deletes  a  descriptor  from the  library base
  187.         socket reference table.   If s is the last reference  to the
  188.         underlying object, then the object  will  be deactivated and
  189.         socket  (see socket()),  associated naming  information  and
  190.         queued data are discarded.
  191.  
  192.         All sockets are automatically closed when the socket library
  193.         is closed, but closing sockets as soon as possible is
  194.         recommended to save system resources.
  195.  
  196.    RETURN VALUES
  197.          0   on success.
  198.  
  199.         -1   on failure and sets errno to indicate the error.
  200.  
  201.    ERRORS
  202.         EBADF             - s is not an active socket descriptor.
  203.  
  204.         EINTR             - linger on close was interrupted.
  205.                             The socket is closed, however.
  206.  
  207.    SEE ALSO
  208.         accept(), SocketBaseTagList(), shutdown(), socket(),
  209.         exec.library/CloseLibrary()
  210. bsdsocket.library/connect                           bsdsocket.library/connect
  211.  
  212.    NAME
  213.         connect - initiate a connection on a socket
  214.    
  215.    SYNOPSIS
  216.         #include <sys/types.h>
  217.         #include <sys/socket.h>
  218.    
  219.         success = connect(s, name, namelen)
  220.         D0                D0 A0    D1
  221.    
  222.         long connect(long, struct sockaddr *, long);
  223.    
  224.    FUNCTION
  225.         The parameter s is a socket.  If it  is of  type SOCK_DGRAM,
  226.         then  this call specifies the peer with which the  socket is
  227.         to be associated;  this address  is that  to which datagrams
  228.         are  to be sent, and  the only address from which  datagrams
  229.         are to be received.  If it is of type SOCK_STREAM, then this
  230.         call attempts  to make a connection  to another socket.  The
  231.         other socket is specified by name which is an address in the
  232.         communications space of  the  socket.   Each  communications
  233.         space interprets the  name parameter in  its  own way.  Gen-
  234.         erally, stream sockets may successfully connect() only once;
  235.         datagram sockets may use connect() multiple  times to change
  236.         their association.  Datagram sockets may dissolve the  asso-
  237.         ciation by connecting to  an invalid address, such as a null
  238.         address.
  239.    
  240.    RETURN VALUES
  241.          0   on success.
  242.    
  243.         -1   on failure and sets errno to indicate the error.
  244.    
  245.    ERRORS
  246.         EADDRINUSE        - The address is already in use.
  247.    
  248.         EADDRNOTAVAIL     - The specified address is  not  available
  249.                             on the remote machine.
  250.    
  251.         EAFNOSUPPORT      - Addresses in the specified address  fam-
  252.                             ily cannot be used with this socket.
  253.    
  254.         EALREADY          - The socket is non-blocking and a  previ-
  255.                             ous  connection attempt has not yet been
  256.                             completed.
  257.    
  258.         EBADF             - s is not a valid descriptor.
  259.    
  260.         ECONNREFUSED      - The attempt to  connect  was  forcefully
  261.                             rejected.   The  calling  program should
  262.                             CloseSocket() the socket descriptor, and
  263.                             issue another socket()  call to obtain a
  264.                             new descriptor before attempting another
  265.                             connect() call.
  266.    
  267.         EINPROGRESS       - The socket is non-blocking and the  con-
  268.                             nection cannot be completed immediately.
  269.                             It is possible to select()  for  comple-
  270.                             tion  by  selecting the socket for writ-
  271.                             ing.
  272.    
  273.         EINTR             - The operation was interrupted by a break 
  274.                             signal.
  275.  
  276.         EINVAL            - namelen is  not  the  size  of  a  valid
  277.                             address  for  the specified address fam-
  278.                             ily.
  279.    
  280.         EISCONN             The socket is already connected.
  281.    
  282.         ENETUNREACH       - The network is not reachable  from  this
  283.                             host.
  284.    
  285.         ETIMEDOUT         - Connection   establishment   timed   out
  286.                             without establishing a connection.
  287.         
  288.    SEE ALSO
  289.         accept(), CloseSocket(), connect(), getsockname(), select(),
  290.         socket()
  291. bsdsocket.library/Dup2Socket                     bsdsocket.library/Dup2Socket
  292.  
  293.    NAME
  294.        Dup2Socket - duplicate a socket descriptor
  295.  
  296.    SYNOPSIS
  297.  
  298.        newfd = Dup2Socket(fd1, fd2)
  299.        D0                 D0   D1
  300.  
  301.        long Dup2Socket(long, long);
  302.  
  303.    DESCRIPTION
  304.        Dup2Socket() duplicates an existing socket descriptor. 
  305.        the argument fd1 is small non-negative value that indexes
  306.        the socket on SocketBase descriptor table. The value must
  307.        be less than the size of the table, which is returned by
  308.        getdtablesize(). fd2 specifies the desired value of the new
  309.        descriptor. If descriptor fd2 is already in use, it is 
  310.        first deallocated as if it were closed by CloseSocket(). If
  311.        the value if fd2 is -1, the new descriptor used and returned
  312.        is the lowest numbered descriptor that is not currently in 
  313.        use by the SocketBase.
  314.  
  315.        Dup2Socket() has also an feature to mark a file descriptor as
  316.        being used. If fd1 is given as -1, fd2 is marked as being used
  317.        socket descriptor table and it won't be allocated for any
  318.        socket. This mark can be removed using CloseSocket() call.
  319.  
  320.    RETURN VALUES
  321.        Dup2Socket() returns a new descriptor on  success. On failure
  322.        -1 is returned and errno is set to indicate the error.
  323.  
  324.    ERRORS
  325.        EBADF          fd1 or fd2 is not a valid active descriptor.
  326.  
  327.        EMFILE         Too many descriptors are active.
  328.  
  329.    SEE ALSO
  330.        accept(), CloseSocket(), getdtablesize(), SocketBaseTagList(),
  331.        socket()
  332.  
  333. bsdsocket.library/Errno                               bsdsocket.library/Errno
  334.  
  335.    NAME
  336.         Errno - get error value after unsuccessful function call
  337.  
  338.    SYNOPSIS
  339.         errno = Errno()
  340.         D0
  341.  
  342.         LONG Errno(VOID);
  343.  
  344.    FUNCTION
  345.         When  some  function  in  socket  library  return  an  error
  346.         condition value, they also set a specific error value.  This
  347.         error value can be extracted by this function.
  348.  
  349.    RESULT
  350.         Error value  indicating  the error on  last failure  of some
  351.         socket function call.
  352.  
  353.    NOTES
  354.         Return  value  of  Errno()  is not changed  after successful
  355.         function so so it cannot be used to determine success of any
  356.         function call  of this library.  Also, another function call
  357.         to this  library may change  the return value of  Errno() so
  358.         use it right after error occurred.
  359.  
  360.    SEE ALSO
  361.         SetErrnoPtr()
  362.  
  363. bsdsocket.library/getdtablesize               bsdsocket.library/getdtablesize
  364.  
  365.    NAME
  366.        getdtablesize - get socket descriptor table size
  367.  
  368.    SYNOPSIS
  369.  
  370.        nfds = getdtablesize()
  371.        D0
  372.  
  373.        long getdtablesize(void);
  374.  
  375.    FUNCTION
  376.        Return value of maximum  number of open socket  descriptors.
  377.        Larger  socket  descriptor  table  can   be  allocated  with
  378.        SocketBaseTagList() call.
  379.  
  380.    SEE ALSO
  381.        SocketBaseTagList()
  382.  
  383. bsdsocket.library/gethostbyaddr               bsdsocket.library/gethostbyaddr
  384.  
  385.    SEE ALSO
  386.         gethostbyname()
  387.  
  388. bsdsocket.library/gethostbyname               bsdsocket.library/gethostbyname
  389.  
  390.    NAME
  391.         gethostbyname, gethostbyaddr  - get network host entry
  392.  
  393.    SYNOPSIS
  394.         #include <sys/types.h>
  395.         #include <sys/socket.h>
  396.         #include <netdb.h>
  397.  
  398.         hostent = gethostbyname(name)
  399.         D0                      A0
  400.  
  401.         struct hostent *gethostbyname(char *);
  402.  
  403.         hostent = gethostbyaddr(addr, len, type)
  404.         D0                      A0    D0   D1
  405.  
  406.         struct hostent *gethostbyaddr(caddr_t, LONG, LONG);
  407.  
  408.  
  409.    DESCRIPTION 
  410.         gethostbyname() and gethostbyaddr() both return a pointer
  411.         to an object with the following structure containing the
  412.         data received from a name server or the broken-out fields
  413.         of a line in netdb configuration file.  In the case of
  414.         gethostbyaddr(), addr is a pointer to the binary format
  415.         address of length len (not a character string) and type is
  416.         an address family as defined in <sys/socket.h>. 
  417.  
  418.           struct hostent {
  419.             char *h_name;       /* official name of host */
  420.             char **h_aliases;   /* alias list */
  421.             int  h_addrtype;    /* address type */
  422.             int  h_length;      /* length of address */
  423.             char **h_addr_list; /* list of addresses from name server */
  424.           };
  425.  
  426.         The members of this structure are:
  427.  
  428.         h_name              Official name of the host.
  429.  
  430.         h_aliases           A zero  terminated  array  of  alternate
  431.                             names for the host.
  432.  
  433.         h_addrtype          The  type  of  address  being  returned;
  434.                             currently always AF_INET.
  435.  
  436.         h_length            The length, in bytes, of the address.
  437.  
  438.         h_addr_list         A pointer to a list of network addresses
  439.                             for  the named host.  Host addresses are
  440.                             returned in network byte order.
  441.  
  442.    DIAGNOSTICS
  443.         A NULL pointer is returned if no matching entry was found or 
  444.         error occured.
  445.  
  446.    BUGS
  447.         All information is contained in a static area so it must  be
  448.         copied if it is to be saved.  Only the Internet address for-
  449.         mat is currently understood.
  450.  
  451.    SEE ALSO
  452.         AmiTCP/IP configuration
  453.  
  454. bsdsocket.library/gethostid                       bsdsocket.library/gethostid
  455.  
  456.    NAME   
  457.        gethostid -- get an unique 32-bit id to this host
  458.  
  459.    SYNOPSIS
  460.        id = gethostid();
  461.  
  462.        ULONG gethostid(void);
  463.  
  464.    FUNCTION
  465.        Return the 32-bit unique id for this host. The Internet
  466.        address if the primary interface is used as the unique id.
  467.        This means that this function is also a supported way to get
  468.        the hosts IP address in AmiTCP/IP. If no interfaces are
  469.        configured, zero is returned. Any non-loobpack interface with
  470.        is preferred. Only if no other interfaces are present, is the
  471.        loopback address returned.
  472.        
  473.    INPUTS
  474.  
  475.    RESULT
  476.        id  - non-zero on success.
  477.   
  478.    EXAMPLE
  479.        ULONG id;
  480.        
  481.        id = gethostid();
  482.        if (id == 0)
  483.          exit(10);
  484.        
  485.        printf("My primary IP address is: %s.\n", Inet_NtoA(id));
  486.  
  487.    NOTES
  488.        Non-zero id is returned as soon as a interface is configured.
  489.        After that the id will not change, not even if the id is the
  490.        address of the loopback interface.
  491.  
  492.    BUGS
  493.  
  494.    SEE ALSO
  495. bsdsocket.library/gethostname                   bsdsocket.library/gethostname
  496.  
  497.    NAME   
  498.        gethostname -- get the name of the host
  499.  
  500.    SYNOPSIS
  501.        error = gethostname(name, namelen);
  502.  
  503.        long gethostname(char *, long);
  504.  
  505.    FUNCTION
  506.        Get the name of the host to the buffer name of length namelen.
  507.        The name is queried from the netdb and/or the name server if 
  508.        it is not explicitly configured (configuration variable
  509.        HOSTNAME).
  510.  
  511.    INPUTS
  512.        name    - Pointer to the buffer where the name should be
  513.                  stored.
  514.        namelen - Length of the buffer name.
  515.  
  516.    RESULT
  517.        error   - 0 on success.
  518.   
  519.    EXAMPLE
  520.        char hostname[MAXHOSTNAMELEN];
  521.        long error;
  522.        
  523.        error = gethostname(hostname, sizeof(hostname));
  524.        if (error < 0)
  525.          exit(10);
  526.        
  527.        printf("My name is \"%s\".\n", hostname);
  528.  
  529.    NOTES
  530.  
  531.    BUGS
  532.        Unlike the Unix version, this version assures that the
  533.        resulting string is always NULL-terminated.
  534.  
  535.    SEE ALSO
  536.        gethostid()
  537. bsdsocket.library/getnetbyaddr                 bsdsocket.library/getnetbyaddr
  538.  
  539.    SEE ALSO
  540.         getnetbyname()
  541.  
  542. bsdsocket.library/getnetbyname                 bsdsocket.library/getnetbyname
  543.  
  544.    NAME
  545.         getnetbyname, getnetbyaddr - get network entry
  546.  
  547.    SYNOPSIS
  548.         #include <netdb.h>
  549.  
  550.         netent = getnetbyname(name)
  551.         D0                    A0
  552.  
  553.         struct netent *getnetbyname(char *);
  554.  
  555.         netent = getnetbyaddr(net, type)
  556.         D0                    D0   D1
  557.  
  558.         struct netent *getnetbyaddr(long, long);
  559.  
  560.    DESCRIPTION
  561.         getnetbyname(), and getnetbyaddr() both return  a  pointer to
  562.         an  object  with  the  following  structure  containing   the
  563.         broken-out fields of a line in netdb configuration file.
  564.  
  565.           struct netent {
  566.             char *n_name;       /* official name of net */
  567.             char **n_aliases;   /* alias list */
  568.             int  n_addrtype;    /* net number type */
  569.             long n_net;         /* net number */
  570.           };
  571.  
  572.         The members of this structure are:
  573.  
  574.         n_name              The official name of the network.
  575.  
  576.         n_aliases           A  zero  terminated  list  of  alternate
  577.                             names for the network.
  578.  
  579.         n_addrtype          The type of the network number returned;
  580.                             currently only AF_INET.
  581.  
  582.         n_net               The network number.  Network numbers are
  583.                             returned in machine byte order.
  584.  
  585.         Network numbers are supplied in host order.
  586.  
  587.         Type specifies the address type to use, currently only
  588.         AF_INET is supported.
  589.  
  590.    DIAGNOSTICS
  591.         A NULL pointer is returned if no matching entry was found or 
  592.         error occured.
  593.  
  594.    BUGS
  595.         All information is contained in a static area so it must  be
  596.         copied if it is to be saved.
  597.  
  598.         Only Internet network numbers are currently understood.
  599.  
  600.    SEE ALSO
  601.         AmiTCP/IP configuration
  602.  
  603. bsdsocket.library/getpeername                   bsdsocket.library/getpeername
  604.  
  605.    NAME
  606.         getpeername - get name of connected peer
  607.  
  608.    SYNOPSIS
  609.         success =  getpeername(s, name, namelen)
  610.         D0                     D0 A0    A1
  611.  
  612.         long getpeername(long, struct sockaddr *, long *);
  613.  
  614.    FUNCTION
  615.         getpeername() returns the name  of  the  peer  connected  to
  616.         socket  s.   The long  pointed  to  by the namelen parameter
  617.         should be  initialized  to  indicate  the  amount  of  space
  618.         pointed  to  by name.  On return it contains the actual size
  619.         of the name returned (in bytes).  The name is  truncated  if
  620.         the buffer provided is too small.
  621.  
  622.    RETURN VALUE
  623.         A 0 is returned if the call succeeds, -1 if it fails.
  624.  
  625.    ERRORS
  626.         EBADF        - The argument s is not a valid descriptor.
  627.  
  628.         ENOBUFS      - Insufficient resources were available in  the
  629.                        system to perform the operation.
  630.  
  631.         ENOTCONN     - The socket is not connected.
  632.  
  633.    SEE ALSO
  634.         accept(), bind(), getsockname(), socket()
  635. bsdsocket.library/getprotobyname             bsdsocket.library/getprotobyname
  636.  
  637.    NAME
  638.         getprotobyname, getprotobynumber - get protocol entry
  639.  
  640.    SYNOPSIS
  641.         #include <netdb.h>
  642.  
  643.         protoent = getprotobyname(name)
  644.         D0                        A0
  645.  
  646.         struct protoent *getprotobyname(char *);
  647.  
  648.         protoent = getprotobynumber(proto)
  649.         D0                          D0
  650.  
  651.         struct protoent *getprotobynumber(long);
  652.  
  653.    DESCRIPTION
  654.         getprotobyname() and getprotobynumber() both return a pointer
  655.         to  an  object with the  following structure  containing  the
  656.         broken-out fields of a line in netdb configuration file
  657.  
  658.           struct    protoent {
  659.             char *p_name;       /* official name of protocol */
  660.             char **p_aliases;   /* alias list */
  661.             int  p_proto;       /* protocol number */
  662.          };
  663.  
  664.         The members of this structure are:
  665.  
  666.         p_name              The official name of the protocol.
  667.         p_aliases           A  zero  terminated  list  of  alternate
  668.                             names for the protocol.
  669.         p_proto             The protocol number.
  670.  
  671.  
  672.    DIAGNOSTICS
  673.         A NULL pointer is returned if no matching entry was found or 
  674.         error occured.
  675.  
  676.    BUGS
  677.         All information is contained in a static area so it must  be
  678.         copied  if  it  is to be saved.  Only the Internet protocols
  679.         are currently understood.
  680.  
  681.    SEE ALSO
  682.         AmiTCP/IP configuration
  683.  
  684. bsdsocket.library/getprotobynumber         bsdsocket.library/getprotobynumber
  685.  
  686.    SEE ALSO
  687.         getprotobyname()
  688.  
  689. bsdsocket.library/getservbyname               bsdsocket.library/getservbyname
  690.  
  691.    NAME
  692.         getservbyname, getservbyport - get service entry
  693.  
  694.    SYNOPSIS
  695.         #include <netdb.h>
  696.  
  697.         servent = getservbyname(name, proto)
  698.         D0                      A0    A1
  699.  
  700.         struct servent *getservbyname(char *, char *)
  701.  
  702.         servent = getservbyport(port, proto)
  703.         D0                      D0    A0
  704.  
  705.         struct servent *getservbyport(long, char *);
  706.  
  707.    DESCRIPTION
  708.         getservbyname() and getservbyport() both return a pointer  to
  709.         an   object  with  the  following  structure  containing  the
  710.         broken-out fields of a line in netdb configuration file.
  711.  
  712.           struct    servent {
  713.             char *s_name;       /* official name of service */
  714.             char **s_aliases;   /* alias list */
  715.             int  s_port;        /* port service resides at */
  716.             char *s_proto;      /* protocol to use */
  717.           };
  718.  
  719.         The members of this structure are:
  720.              s_name              The official name of the service.
  721.              s_aliases           A zero terminated list of alternate
  722.                                  names for the service.
  723.              s_port              The port number at which  the  ser-
  724.                                  vice  resides.   Port  numbers  are
  725.                                  returned  in  network  short   byte
  726.                                  order.
  727.              s_proto             The name of  the  protocol  to  use
  728.                                  when contacting the service.
  729.  
  730.         The proto argument specifies the protocol for which to the
  731.         sercive is to use. It is a normal C string, e.g. "tcp" or
  732.         "udp".
  733.  
  734.    DIAGNOSTICS
  735.         A NULL pointer is returned if no matching entry was found or 
  736.         error occured.
  737.  
  738.    BUGS
  739.         All information is contained in a static area so it must  be
  740.         copied  if it is to be saved.  Expecting port numbers to fit
  741.         in a 32 bit quantity is probably naive.
  742.  
  743.    SEE ALSO
  744.         AmiTCP/IP configuration
  745.  
  746. bsdsocket.library/getservbyport               bsdsocket.library/getservbyport
  747.  
  748.    SEE ALSO
  749.         getservbyname()
  750.  
  751. bsdsocket.library/getsockname                   bsdsocket.library/getsockname
  752.  
  753.    NAME
  754.         getsockname - get socket name
  755.  
  756.    SYNOPSIS
  757.  
  758.         success = getsockname(s, name, namelen)
  759.         D0                    D0 A0    A1
  760.  
  761.         long getsockname(long, struct sockaddr *, long *);
  762.  
  763.    FUNCTION
  764.         getsockname() returns the current  name  for  the  specified
  765.         socket.   The  namelen  parameter  should  be initialized to
  766.         indicate the amount of space pointed to by name.  On  return
  767.         it contains the actual size of the name returned (in bytes).
  768.  
  769.    DIAGNOSTICS
  770.         A 0 is returned if the call succeeds, -1 if it fails.
  771.  
  772.    ERRORS
  773.         The call succeeds unless:
  774.  
  775.         EBADF          s is not a valid descriptor.
  776.  
  777.         ENOBUFS        Insufficient resources were available in  the
  778.                        system to perform the operation.
  779.  
  780.    SEE ALSO
  781.         bind(), getpeername(), socket()
  782. bsdsocket.library/getsockopt                     bsdsocket.library/getsockopt
  783.  
  784.    NAME
  785.         getsockopt, setsockopt - get and set options on sockets
  786.  
  787.    SYNOPSIS
  788.         #include <sys/types.h>
  789.         #include <sys/socket.h>
  790.  
  791.         success =  getsockopt(s, level, optname, optval, optlen)
  792.         D0                    D0 D1     D2       A0      A1
  793.         
  794.         long getsockopt(long, long, long, caddr_t, long *);
  795.  
  796.         success =  setsockopt(s, level, optname, optval, optlen)
  797.         D0                    D0 D1     D2       A0      D3
  798.         
  799.         long setsockopt(long, long, long, caddr_t, long);
  800.  
  801.    FUNCTION
  802.         getsockopt() and setsockopt() manipulate options  associated
  803.         with  a socket.  Options may exist at multiple protocol lev-
  804.         els; they are always present  at  the  uppermost  ``socket''
  805.         level.
  806.  
  807.         When manipulating socket options  the  level  at  which  the
  808.         option resides and the name of the option must be specified.
  809.         To manipulate options at  the  ``socket''  level,  level  is
  810.         specified as SOL_SOCKET.  To manipulate options at any other
  811.         level the protocol number of the appropriate  protocol  con-
  812.         trolling  the  option is supplied.  For example, to indicate
  813.         that an option is to be interpreted  by  the  TCP  protocol,
  814.         level  should  be  set  to  the  protocol number of TCP.
  815.  
  816.         The parameters optval and optlen are used to  access  option
  817.         values  for  setsockopt().  For getsockopt() they identify a
  818.         buffer in which the value for the requested option(s) are to
  819.         be  returned.   For  getsockopt(),  optlen is a value-result
  820.         parameter, initially  containing  the  size  of  the  buffer
  821.         pointed to by optval, and modified on return to indicate the
  822.         actual size of the value returned.  If no option value is to
  823.         be supplied or returned, optval may be supplied as 0.
  824.  
  825.         optname and any specified options are  passed  uninterpreted
  826.         to  the appropriate protocol module for interpretation.  The
  827.         include  file  <sys/socket.h>   contains   definitions   for
  828.         ``socket'' level options, described below.  Options at other
  829.         protocol  levels  vary  in  format  and  name.
  830.  
  831.         Most socket-level options take an int parameter for  optval.
  832.         For setsockopt(), the parameter should be non-zero to enable
  833.         a boolean option, or zero if the option is to  be  disabled.
  834.  
  835.         SO_LINGER   uses  a  struct  linger  parameter,  defined  in
  836.         <sys/socket.h>, which specifies the  desired  state  of  the
  837.         option and the linger interval (see below).
  838.  
  839.         The following options are recognized at  the  socket  level.
  840.         Except  as noted, each may be examined with getsockopt() and
  841.         set with setsockopt().
  842.  
  843.              SO_DEBUG          - toggle   recording   of   debugging
  844.                                  information
  845.              SO_REUSEADDR      - toggle local address reuse
  846.              SO_KEEPALIVE      - toggle keep connections alive
  847.              SO_DONTROUTE      - toggle routing bypass for  outgoing
  848.                                  messages
  849.              SO_LINGER         - linger on close if data present
  850.              SO_BROADCAST      - toggle   permission   to   transmit
  851.                                  broadcast messages
  852.              SO_OOBINLINE      - toggle  reception  of   out-of-band
  853.                                  data in band
  854.              SO_SNDBUF         - set buffer size for output
  855.              SO_RCVBUF         - set buffer size for input
  856.              SO_TYPE           - get the type  of  the  socket  (get
  857.                                  only)
  858.              SO_ERROR          - get and clear error on  the  socket
  859.                                  (get only)
  860.  
  861.         SO_DEBUG  enables  debugging  in  the  underlying   protocol
  862.         modules.   SO_REUSEADDR  indicates  that  the  rules used in
  863.         validating addresses supplied in a bind() call should allow
  864.         reuse of local addresses.  SO_KEEPALIVE enables the periodic
  865.         transmission of messages on a connected socket.  Should  the
  866.         connected  party fail to respond to these messages, the con-
  867.         nection is considered broken. If  the  process  is
  868.         waiting in select() when the connection is broken, select()
  869.         returns true for any read or write events selected  for  the
  870.         socket.    SO_DONTROUTE  indicates  that  outgoing  messages
  871.         should bypass the  standard  routing  facilities.   Instead,
  872.         messages  are  directed to the appropriate network interface
  873.         according to the network portion of the destination address.
  874.  
  875.         SO_LINGER controls the action taken when unsent messags  are
  876.         queued  on  socket and a CloseSocket() is performed.  If the
  877.         socket promises reliable delivery of data and  SO_LINGER  is
  878.         set,  the  system  will  block  the  process  on the close
  879.         attempt until it is able to transmit the data  or  until  it
  880.         decides  it  is unable to deliver the information (a timeout
  881.         period, in seconds, termed the linger interval, is specified
  882.         in the set- sockopt() call when SO_LINGER is requested).  If
  883.         SO_LINGER  is  disabled and a CloseSocket()  is  issued, the
  884.         system will process the  close  in  a manner that allows the
  885.         process to continue as quickly as possible.
  886.  
  887.         The option SO_BROADCAST requests permission to  send  broad-
  888.         cast  datagrams  on  the socket.  Broadcast was a privileged
  889.         operation in earlier versions of the system.  With protocols
  890.         that  support  out-of-band  data,  the  SO_OOBINLINE  option
  891.         requests that out-of-band data be placed in the normal  data
  892.         input  queue  as  received;  it will then be accessible with
  893.         recv() or read() calls without the MSG_OOB flag.   SO_SNDBUF
  894.         and  SO_RCVBUF are options to adjust the normal buffer sizes
  895.         allocated for output and input buffers,  respectively.   The
  896.         buffer size may be increased for high-volume connections, or
  897.         may be decreased to limit the possible backlog  of  incoming
  898.         data.   The system places an absolute limit on these values.
  899.         Finally, SO_TYPE and SO_ERROR are  options  used  only  with
  900.         getsockopt().   SO_TYPE returns the type of the socket, such
  901.         as SOCK_STREAM; it is useful for servers that inherit  sock-
  902.         ets  on  startup.  SO_ERROR returns any pending error on the
  903.         socket and clears the error status.  It may be used to check
  904.         for asynchronous errors on connected datagram sockets or for
  905.         other asynchronous errors.
  906.  
  907.    RETURN VALUES
  908.          0 - on success.
  909.  
  910.         -1 - on failure and set errno to indicate the error.
  911.  
  912.    ERRORS
  913.         EBADF             - s is not a valid descriptor.
  914.  
  915.         ENOPROTOOPT       - The option is unknown at the level indi-
  916.                             cated.
  917.  
  918.    SEE ALSO
  919.         IoctlSocket(), socket()
  920.  
  921.    BUGS
  922.         Several of the socket options should  be  handled  at  lower
  923.         levels of the system.
  924. bsdsocket.library/inet_addr                       bsdsocket.library/inet_addr
  925.  
  926.    NAME
  927.         inet_addr,  inet_network,  Inet_MakeAddr,  Inet_LnaOf,
  928.         Inet_NetOf, Inet_NtoA - Internet address manipulation
  929.  
  930.         inet_makeaddr, inet_lnaof, inet_netof,
  931.         inet_ntoa -- inline/stub functions to handle structure arguments
  932.  
  933.    SYNOPSIS
  934.         #include <netinet/in.h>
  935.  
  936.         addr = inet_addr(cp)
  937.         D0               A0
  938.  
  939.         unsigned long inet_addr(char *);
  940.  
  941.         net = inet_network(cp)
  942.         D0                 A0
  943.         
  944.         unsigned long inet_network(char *);
  945.  
  946.         in_addr = Inet_MakeAddr(net, lna)
  947.         D0                      D0   D1
  948.  
  949.         unsigned long Inet_MakeAddr(long, long);
  950.  
  951.         lna = Inet_LnaOf(in)
  952.         D0               D0
  953.  
  954.         long Inet_LnaOf(unsigned long);
  955.  
  956.         net = Inet_NetOf(in)
  957.         D0               D0
  958.  
  959.         long Inet_NetOf(unsigned long);
  960.  
  961.         addr = Inet_NtoA(in)
  962.         DO               D0
  963.  
  964.         char * Inet_NtoA(unsigned long);
  965.  
  966.         
  967.         in_addr = inet_makeaddr(net, lna)
  968.  
  969.         struct in_addr inet_makeaddr(long, long);
  970.  
  971.         lna = inet_lnaof(in)
  972.  
  973.         int inet_lnaof(struct in_addr);
  974.  
  975.         net = inet_netof(in)
  976.  
  977.         int inet_netof(struct in_addr);
  978.  
  979.         addr = inet_ntoa(in)
  980.  
  981.         char * inet_ntoa(struct in_addr);
  982.  
  983.    IMPLEMENTATION NOTE
  984.         Return  value  of  Inet_MakeAddr()  and  argument  types  of
  985.         Inet_LnaOf(), Inet_NetOf() and Inet_NtoA() are longs instead
  986.         of  struct  in_addr.  The original behaviour  is achieved by
  987.         using  included  stub  functions (lower case function names)
  988.         which handle structure arguments.
  989.  
  990.    DESCRIPTION
  991.         The routines inet_addr() and inet_network()  each  interpret
  992.         character  strings  representing  numbers  expressed  in the
  993.         Internet standard `.' notation, returning  numbers  suitable
  994.         for  use as Internet addresses and Internet network numbers,
  995.         respectively.  The routine inet_makeaddr() takes an Internet
  996.         network number and a local network address and constructs an
  997.         Internet address from it.   The  routines  inet_netof()  and
  998.         inet_lnaof()  break apart Internet host addresses, returning
  999.         the network number and local network address  part,  respec-
  1000.         tively.
  1001.  
  1002.         The routine inet_ntoa() returns a pointer to a string in the
  1003.         base 256 notation ``d.d.d.d'' described below.
  1004.  
  1005.         All Internet address are returned in  network  order  (bytes
  1006.         ordered  from left to right).  All network numbers and local
  1007.         address parts are returned as machine format integer values.
  1008.  
  1009.    INTERNET ADDRESSES
  1010.         Values specified using the `.'  notation  take  one  of  the
  1011.  
  1012.         following forms:
  1013.  
  1014.              a.b.c.d
  1015.              a.b.c
  1016.              a.b
  1017.              a
  1018.  
  1019.         When four parts are specified, each is interpreted as a byte
  1020.         of data and assigned, from left to right, to  the four bytes
  1021.         of  an Internet address.  Note: when  an Internet address is
  1022.         viewed  as  a  32-bit  integer  quantity  on  little  endian
  1023.         systems,  the  bytes referred to  above appear  as  d.c.b.a.
  1024.         bytes are ordered from right to left.
  1025.  
  1026.         When a three part address is specified,  the  last  part  is
  1027.         interpreted  as  a  16-bit  quantity and placed in the right
  1028.         most two bytes of the network address.  This makes the three
  1029.         part  address  format convenient for specifying Class B net-
  1030.         work addresses as "128.net.host".
  1031.  
  1032.         When a two part address is supplied, the last part is inter-
  1033.         preted  as  a  24-bit  quantity and placed in the right most
  1034.         three bytes of the network address.  This makes the two part
  1035.         address  format  convenient  for  specifying Class A network
  1036.         addresses as "net.host".
  1037.  
  1038.         When only one part is given, the value is stored directly in
  1039.         the network address without any byte rearrangement.
  1040.  
  1041.         All numbers supplied as ``parts'' in a `.' notation  may  be
  1042.         decimal,  octal,  or  hexadecimal,  as  specified  in  the C
  1043.         language (that is, a leading 0x or 0X  implies  hexadecimal;
  1044.         otherwise,  a leading 0 implies octal; otherwise, the number
  1045.         is interpreted as decimal).
  1046.  
  1047.    RETURN VALUE
  1048.         The value -1 is returned by inet_addr()  and  inet_network()
  1049.         for malformed requests.
  1050.  
  1051.    BUGS
  1052.         The problem of host byte ordering versus network byte order-
  1053.         ing  is  confusing.  A simple way to specify Class C network
  1054.         addresses in a manner similar to that for Class B and  Class
  1055.         A is needed.
  1056.  
  1057.         The return value from inet_ntoa() points to static buffer
  1058.         which  is  overwritten  in  each inet_ntoa() call.
  1059.  
  1060. bsdsocket.library/Inet_LnaOf                     bsdsocket.library/Inet_LnaOf
  1061.  
  1062.    SEE ALSO
  1063.        inet_addr()
  1064.  
  1065. bsdsocket.library/inet_MakeAddr               bsdsocket.library/inet_MakeAddr
  1066.  
  1067.    SEE ALSO
  1068.        inet_addr()
  1069.  
  1070. bsdsocket.library/Inet_NetOf                     bsdsocket.library/Inet_NetOf
  1071.  
  1072.    SEE ALSO
  1073.        inet_addr()
  1074.  
  1075. bsdsocket.library/inet_network                 bsdsocket.library/inet_network
  1076.  
  1077.    SEE ALSO
  1078.        inet_addr()
  1079.  
  1080. bsdsocket.library/Inet_NtoA                       bsdsocket.library/Inet_NtoA
  1081.  
  1082.    SEE ALSO
  1083.        inet_addr()
  1084.  
  1085. bsdsocket.library/IoctlSocket                   bsdsocket.library/IoctlSocket
  1086.  
  1087.    NAME
  1088.         IoctlSocket - control sockets
  1089.  
  1090.    SYNOPSIS
  1091.  
  1092.         #include <sys/types.h>
  1093.         #include <sys/ioctl.h>
  1094.  
  1095.         value = IoctlSocket(fd, request, arg)
  1096.         D0            D0  D1       A0
  1097.  
  1098.         long IoctlSocket(long, long, caddr_t);
  1099.  
  1100.    FUNCTION
  1101.         IoctlSocket() performs a special function on the object referred
  1102.         to by the open  socket descriptor fd. Note: the setsockopt()
  1103.         call (see getsockopt()) is the primary  method for operating
  1104.         on sockets  as such, rather than on the underlying  protocol
  1105.         or network interface.
  1106.  
  1107.         For most IoctlSocket() functions, arg is a pointer to data to
  1108.         be used by the  function  or to be filled in by the function.
  1109.         Other functions may ignore arg or may treat it directly as a
  1110.         data item; they may, for example, be passed an int value.
  1111.  
  1112.         The following requests are supported:
  1113.  
  1114.  
  1115.         FIOASYNC            The argument is a  pointer  to  a  long.
  1116.                             Set  or  clear asynchronous I/O.  If the
  1117.                             value of that  long is  a  1  (one)  the
  1118.                             descriptor  is set for asynchronous I/O.
  1119.                             If the value of that long is a  0 (zero)
  1120.                             the  descriptor is cleared for asynchro-
  1121.                             nous I/O.
  1122.  
  1123.         FIOCLEX
  1124.         FIONCLEX            Ignored, no use for close-on-exec flag
  1125.                             in Amiga.
  1126.  
  1127.         FIOGETOWN
  1128.         SIOCGPGRP           The argument is pointer to struct Task*.
  1129.                             Set the value of that pointer to the 
  1130.                             Task that  is  receiving SIGIO or SIGURG
  1131.                             signals for  the  socket  referred to by
  1132.                             the descriptor passed to IoctlSocket().
  1133.  
  1134.         FIONBIO             The argument is a  pointer  to  a  long.
  1135.                             Set  or  clear non-blocking I/O.  If the
  1136.                             value of that  long is  a  1  (one)  the
  1137.                             descriptor  is set for non-blocking I/O.
  1138.                             If the value of that long is a  0 (zero)
  1139.                             the   descriptor  is  cleared  for  non-
  1140.                             blocking I/O.
  1141.  
  1142.         FIONREAD            The argument is a  pointer  to  a  long.
  1143.                             Set the value of that long to the number
  1144.                             of immediately readable characters  from
  1145.                             the socket fd.
  1146.  
  1147.         FIOSETOWN
  1148.         SIOCSPGRP           The argument is pointer to struct Task*,
  1149.                             pointer  to  the task  that will subseq-
  1150.                             uently receive  SIGIO or  SIGURG signals
  1151.                             for   the  socket  referred  to  by  the
  1152.                             descriptor passed.
  1153.  
  1154.         SIOCCATMARK         The argument is a pointer to a long.
  1155.                             Set the value of that long to 1 if the
  1156.                             read pointer for the socket referred to
  1157.                             by the descriptor passed to
  1158.                             IoctlSocket() points to a mark in the
  1159.                             data stream for an out-of-band message,
  1160.                             and to 0 if it does not point to a mark.
  1161.  
  1162.  
  1163.    RETURN VALUES
  1164.         IoctlSocket() returns 0 on success for most requests.   Some 
  1165.         specialized requests may return non-zero values on success; On  
  1166.         failure,  IoctlSocket() returns -1 and sets errno to indicate
  1167.         the error.
  1168.  
  1169.    ERRORS
  1170.         EBADF          fd is not a valid descriptor.
  1171.  
  1172.         EINVAL         request or arg is not valid.
  1173.  
  1174.         IoctlSocket() will also fail if the object on which the function
  1175.         is  being performed detects an error. In this case, an error
  1176.         code specific  to  the  object  and  the  function  will  be
  1177.         returned.
  1178.  
  1179.    SEE ALSO
  1180.         getsockopt(), SocketBaseTagList(), setsockopt()
  1181. bsdsocket.library/listen                             bsdsocket.library/listen
  1182.    NAME
  1183.         listen - listen for connections on a socket
  1184.  
  1185.    SYNOPSIS
  1186.         success = listen(s, backlog)
  1187.         D0               D0 D1
  1188.  
  1189.         long listen(long, long);
  1190.  
  1191.    FUNCTION
  1192.         To accept  connections,  a  socket  is  first  created  with
  1193.         socket(),  a  backlog for incoming connections is specified
  1194.         with listen() and then the  connections  are  accepted  with
  1195.         accept().   The  listen()  call  applies only to socket of
  1196.         type SOCK_STREAM.
  1197.  
  1198.         The backlog parameter defines the maximum length  the  queue
  1199.         of pending connections may grow to.  If a connection request
  1200.         arrives with the queue full the client will receive an error
  1201.         with an indication of ECONNREFUSED.
  1202.  
  1203.    RETURN VALUES
  1204.          0    on success.
  1205.  
  1206.         -1    on failure and sets errno to indicate the error.
  1207.  
  1208.    ERRORS
  1209.         EBADF             - s is not a valid descriptor.
  1210.  
  1211.         EOPNOTSUPP        - The socket is not of a  type  that  sup-
  1212.                             ports listen().
  1213.  
  1214.    SEE ALSO
  1215.         accept(), connect(), socket()
  1216.  
  1217.    BUGS
  1218.         The backlog is currently limited (silently) to 5.
  1219. bsdsocket.library/ObtainSocket                 bsdsocket.library/ObtainSocket
  1220.  
  1221.    NAME
  1222.         ObtainSocket - get a socket from AmiTCP/IP socket list
  1223.  
  1224.    SYNOPSIS
  1225.         s = ObtainSocket(id, domain, type, protocol)
  1226.         D0               D0  D1      D2    D3
  1227.  
  1228.         LONG ObtainSocket(LONG, LONG, LONG, LONG);
  1229.  
  1230.    FUNCTION 
  1231.         When one task wants to give  a socket to  an another one, it
  1232.         releases it (with a key value) to a special socket list held
  1233.         by  AmiTCP/IP.   This  function  requests  that  socket  and
  1234.         receives it if id and other parameters match.
  1235.  
  1236.    INPUTS
  1237.         id       - a key value given by the socket donator.
  1238.         domain   - see documentation of socket().
  1239.         type     - see documentation of socket().
  1240.         protocol - see documentation of socket().
  1241.  
  1242.    RESULT
  1243.         Non negative socket descriptor on success. On failure, -1 is
  1244.         returned and the errno is set to indicate the error.
  1245.  
  1246.    ERRORS
  1247.         EMFILE          - The per-process descriptor table is
  1248.                           full.
  1249.  
  1250.         EPROTONOSUPPORT - The protocol type or the specified  pro-
  1251.                           tocol is not supported within this
  1252.                           domain.
  1253.  
  1254.         EPROTOTYPE      - The protocol is the wrong type for the
  1255.                           socket.
  1256.  
  1257.         EWOULDBLOCK     - Matching socket is not found.
  1258.          
  1259.    SEE ALSO
  1260.         ReleaseCopyOfSocket(), ReleaseSocket(), socket()
  1261.  
  1262. bsdsocket.library/recv                                 bsdsocket.library/recv
  1263.    NAME
  1264.         recv, recvfrom, - receive a message from a socket
  1265.  
  1266.    SYNOPSIS
  1267.         #include <sys/types.h>
  1268.         #include <sys/socket.h>
  1269.  
  1270.        nbytes = recv(s, buf, len, flags)
  1271.        D0            D0 A0   D1   D2
  1272.  
  1273.        long recv(long, char *, long, long);
  1274.  
  1275.        nbytes = recvfrom(s, buf, len, flags, from, fromlen)
  1276.        D0                D0 A0   D1   D2     A1    A2
  1277.  
  1278.        long recvfrom(long, char *, long, long, 
  1279.                         struct sockaddr *, long *);
  1280.  
  1281.    FUNCTION
  1282.         s is a socket created with socket().  recv() and recvfrom(),
  1283.         are used  to  receive messages from  another socket.  recv()
  1284.         may  be  used  only on a connected socket  (see  connect()),
  1285.         while  recvfrom() may be used  to receive data  on a  socket
  1286.         whether it is in a connected state or not.
  1287.  
  1288.         If from is not a NULL pointer, the  source  address  of  the
  1289.         message  is filled in.  fromlen is a value-result parameter,
  1290.         initialized to the size of the buffer associated with  from,
  1291.         and  modified  on  return to indicate the actual size of the
  1292.         address  stored  there.   The  length  of  the  message   is
  1293.         returned.   If  a message is too long to fit in the supplied
  1294.         buffer, excess bytes may be discarded depending on the  type
  1295.         of socket the message is received from (see socket()).
  1296.  
  1297.         If no messages are available at the socket, the receive call
  1298.         waits  for  a  message  to arrive, unless the socket is non-
  1299.         blocking (see IoctlSocket()) in which case -1  is  returned
  1300.         with the external variable errno set to EWOULDBLOCK.
  1301.  
  1302.         The select() call may be used to determine when  more  data
  1303.         arrive.
  1304.  
  1305.         The flags parameter is formed by ORing one or  more  of  the
  1306.         following:
  1307.  
  1308.         MSG_OOB      - Read any "out-of-band" data  present  on  the
  1309.                        socket,  rather  than  the  regular "in-band"
  1310.                        data.
  1311.  
  1312.         MSG_PEEK     - "Peek" at the data present on the socket; the
  1313.                        data  are returned, but not consumed, so that
  1314.                        a subsequent receive operation will  see  the
  1315.                        same data.
  1316.  
  1317.    RETURN VALUES
  1318.         These calls return the number of bytes received, or -1 if an
  1319.         error occurred.
  1320.  
  1321.    ERRORS
  1322.         EBADF             - s is an invalid descriptor.
  1323.  
  1324.         EINTR             - The operation was interrupted by a break 
  1325.                             signal.
  1326.  
  1327.         EWOULDBLOCK       - The socket is  marked  non-blocking  and
  1328.                             the requested operation would block.
  1329.  
  1330.    SEE ALSO
  1331.         connect(), getsockopt(), IoctlSocket(), select(), send(),
  1332.         SocketBaseTagList(), socket()
  1333. bsdsocket.library/recvfrom                         bsdsocket.library/recvfrom
  1334.  
  1335.    SEE ALSO
  1336.         recv()
  1337. bsdsocket.library/ReleaseCopyOfSocket   bsdsocket.library/ReleaseCopyOfSocket
  1338.  
  1339.    NAME
  1340.         ReleaseCopyOfSocket - copy given socket to AmiTCP/IP socket list.
  1341.  
  1342.    SYNOPSIS
  1343.         id = ReleaseCopyOfSocket(fd, id)
  1344.         D0                       D0  D1
  1345.  
  1346.         LONG ReleaseCopyOfSocket(LONG, LONG);
  1347.  
  1348.    FUNCTION
  1349.         Make a new reference to a given socket (pointed by its descriptor)
  1350.         and release it to the socket list held by AmiTCP/IP.
  1351.  
  1352.    INPUTS
  1353.         fd - descriptor of the socket to release.
  1354.  
  1355.         id - the key value to identify use of this socket. It can be
  1356.              unique or not, depending on its  value.  If id value is
  1357.              between 0  and  65535,  inclusively,  it is  considered
  1358.              nonunique  and it can  be  used as a port  number,  for
  1359.              example.   If  id is greater  than  65535 and less than
  1360.              2^31) it  must be unique in currently  held sockets  in
  1361.              AmiTCP/IP socket  list,  Otherwise  an  error  will  be
  1362.              returned  and  socket  is  not  released.    If  id  ==
  1363.              UNIQUE_ID (defined in <sys/socket.h>) an unique id will
  1364.              be generated.
  1365.  
  1366.    RESULT
  1367.         id - -1 in case of error and the key value of the socket put
  1368.              in the list. Most useful when an unique id is generated
  1369.              by this routine. 
  1370.  
  1371.    ERRORS
  1372.         EINVAL - Requested unique id is already used.
  1373.  
  1374.         ENOMEM - Needed memory couldn't be allocated.
  1375.  
  1376.    NOTE
  1377.         The socket descriptor is not deallocated.
  1378.  
  1379.    SEE ALSO
  1380.         ObtainSocket(), ReleaseSocket()
  1381.  
  1382.  
  1383. bsdsocket.library/ReleaseSocket               bsdsocket.library/ReleaseSocket
  1384.  
  1385.    NAME
  1386.         ReleaseSocket - release given socket to AmiTCP/IP socket list.
  1387.  
  1388.    SYNOPSIS
  1389.         id = ReleaseSocket(fd, id)
  1390.         D0                 D0  D1
  1391.  
  1392.         LONG ReleaseSocket(LONG, LONG);
  1393.  
  1394.    FUNCTION
  1395.         Release the reference of given socket (via  its  descriptor)
  1396.         and move the socket to the  socket  list held by  AmiTCP/IP.
  1397.         The socket descriptor is deallocated in this procedure.
  1398.  
  1399.    INPUTS
  1400.         fd - descriptor of the socket to release.
  1401.  
  1402.         id - the key value to identify use of this socket. It can be
  1403.              unique or not, depending on its  value.  If id value is
  1404.              between 0  and  65535,  inclusively,  it is  considered
  1405.              nonunique  and it can  be  used as a port  number,  for
  1406.              example.   If  id is greater  than  65535 and less than
  1407.              2^31) it  must be unique in currently  held sockets  in
  1408.              AmiTCP/IP socket  list,  Otherwise  an  error  will  be
  1409.              returned  and  socket  is  not  released.    If  id  ==
  1410.              UNIQUE_ID (defined in <sys/socket.h>) an unique id will
  1411.              be generated.
  1412.  
  1413.    RESULT
  1414.         id - -1 in case of error and the key value of the socket put
  1415.              in the list. Most useful when an unique id is generated
  1416.              by this routine. 
  1417.  
  1418.    ERRORS
  1419.         EINVAL - Requested unique id is already used.
  1420.  
  1421.         ENOMEM - Needed memory couldn't be allocated.
  1422.  
  1423.    SEE ALSO
  1424.         ObtainSocket(), ReleaseCopyOfSocket()
  1425.  
  1426. bsdsocket.library/select                             bsdsocket.library/select
  1427.  
  1428.    NAME
  1429.         select -- synchronous I/O multiplexing (stub/inline function)
  1430.         WaitSelect -- select() with Amiga Wait() function.
  1431.  
  1432.    SYNOPSIS
  1433.         #include <sys/types.h>
  1434.         #include <sys/time.h>
  1435.  
  1436.         n = select (nfds, readfds, writefds, exceptfds, timeout)
  1437.  
  1438.         long select(long, fd_set *, fd_set *, fd_set *, 
  1439.                     struct timeval *);
  1440.  
  1441.         n = WaitSelect (nfds, readfds, writefds, exceptfds, timeout,
  1442.         D0              D0    A0       A1        A2         A3
  1443.                     sigmp)
  1444.                     D1
  1445.  
  1446.         long WaitSelect(long, fd_set *, fd_set *, fd_set *, 
  1447.                         struct timeval *, long *);
  1448.  
  1449.         FD_SET (fd, &fdset)
  1450.         FD_CLR (fd, &fdset)
  1451.         FD_ISSET (fd, &fdset)
  1452.         FD_ZERO (&fdset)
  1453.         long fd;
  1454.         fd_set fdset;
  1455.  
  1456.    DESCRIPTION
  1457.         select() examines the socket descriptor sets whose addresses
  1458.         are passed in readfds,  writefds,  and exceptfds  to  see if
  1459.         some of their descriptors are ready  for reading,  ready for
  1460.         writing,  or have an exceptional condition pending.  nfds is
  1461.         the  number  of bits to be checked in  each  bit  mask  that
  1462.         represent a file descriptor; the descriptors from 0  through
  1463.         (nfds - 1) in the descriptor sets  are examined.  On return,
  1464.         select()  replaces  the  given descriptor sets  with subsets
  1465.         consisting of  those descriptors  that  are  ready  for  the
  1466.         requested operation.  The total number  of ready descriptors
  1467.         in all the sets is returned.
  1468.  
  1469.         WaitSelect() also takes a signal mask which is waited during
  1470.         normal select() operation. If one of these singals is recei-
  1471.         ved,  WaitSelect() returns  and has  re-set  the signal mask
  1472.         to return those signals that  have arrived.  Normal select()
  1473.         return values are returned.
  1474.  
  1475.         The descriptor sets are stored as bit fields  in  arrays  of
  1476.         integers.   The following macros are provided for manipulat-
  1477.         ing such descriptor sets:  FD_ZERO  (&fdset)  initializes  a
  1478.         descriptor  set  fdset to the null set.  FD_SET(fd, &fdset )
  1479.         includes a particular descriptor fd  in  fdset.   FD_CLR(fd,
  1480.         &fdset)  removes  fd  from  fdset.   FD_ISSET(fd, &fdset) is
  1481.         nonzero if fd is a member of  fdset,  zero  otherwise.   The
  1482.         behavior  of these macros is undefined if a descriptor value
  1483.         is less than zero or greater than or  equal  to  FD_SETSIZE,
  1484.         which  is  normally  at least equal to the maximum number of
  1485.         descriptors supported by the system.
  1486.  
  1487.         If timeout is not a NULL pointer,  it  specifies  a  maximum
  1488.         interval  to wait for the selection to complete.  If timeout
  1489.         is a NULL  pointer,  the  select  blocks  indefinitely.   To
  1490.         effect  a  poll,  the  timeout argument should be a non-NULL
  1491.         pointer, pointing to a zero-valued timeval structure.
  1492.  
  1493.         Any of readfds, writefds, and exceptfds may be given as NULL
  1494.         pointers if no descriptors are of interest.
  1495.  
  1496.         Selecting true for reading on a socket descriptor upon which
  1497.         a  listen() call has been performed indicates that a subse-
  1498.         quent accept() call on that descriptor will not block.
  1499.  
  1500.    RETURN VALUES
  1501.         select() returns a non-negative value on success. A positive
  1502.         value indicates the number of ready descriptors in the
  1503.         descriptor sets. 0 indicates that the time limit referred to
  1504.         by timeout expired or that the operation was interrupted
  1505.         either by a break signal or by arrival of a signal specified
  1506.         in *sigmp. On failure, select() returns -1, sets errno to
  1507.         indicate the error, and the descriptor sets are not changed.
  1508.  
  1509.    ERRORS
  1510.         EBADF        - One  of  the  descriptor  sets  specified  an
  1511.                        invalid descriptor.
  1512.  
  1513.         EINTR        - one of the signals in SIGINTR  mask (see Set-
  1514.                        SocketSignals())   is  set  and  it  was  not
  1515.                        requested in WaitSelect() call.
  1516.  
  1517.         EINVAL       - A component of the pointed-to time  limit  is
  1518.                        outside  the  acceptable range: t_sec must be
  1519.                        between 0 and 10^8, inclusive. t_usec must be
  1520.                        greater  than  or  equal  to 0, and less than
  1521.                        10^6.
  1522.  
  1523.    SEE ALSO
  1524.         accept(),  connect(), getdtablesize(), listen(), recv(),
  1525.         send(), SetDTableSize(), SetSocketSignals()
  1526.  
  1527.    NOTES
  1528.         Under rare  circumstances,  select()  may  indicate  that  a
  1529.         descriptor  is  ready for writing when in fact an attempt to
  1530.         write would block.  This  can  happen  if  system  resources
  1531.         necessary  for  a  write are exhausted or otherwise unavail-
  1532.         able.  If an application deems it critical that writes to  a
  1533.         file  descriptor not block, it should set the descriptor for
  1534.         non-blocking I/O using the FIOASYNC request to IoctlSocket().
  1535.  
  1536.         Default   system   limit  for  open  socket  descriptors  is
  1537.         currently  64. However,  in  order  to accommodate  programs
  1538.         which might  potentially  use  a larger number of open files
  1539.         with select, it is possible  to  increase this size within a
  1540.         program  by  providing  a  larger definition  of  FD_SETSIZE
  1541.         before    the   inclusion    of   <sys/types.h>    and   use
  1542.         SocketBaseTags(SBTM_SETVAL(SBTC_DTABLESIZE), FD_SETSIZE);
  1543.         call directly after OpenLibrary().
  1544.  
  1545.    BUGS
  1546.         select() should probably return the time remaining from  the
  1547.         original  timeout,  if  any,  by modifying the time value in
  1548.         place.  This may be implemented in future  versions  of  the
  1549.         system.   Thus,  it  is  unwise  to  assume that the timeout
  1550.         pointer will be unmodified by the select() call.
  1551. bsdsocket.library/send                                 bsdsocket.library/send
  1552.  
  1553.    NAME
  1554.         send, sendto - send a message from a socket
  1555.  
  1556.    SYNOPSIS
  1557.         #include <sys/types.h>
  1558.         #include <sys/socket.h>
  1559.  
  1560.         nbytes = send(s, msg, len, flags)
  1561.         D0            D0 A0   D1   D2
  1562.  
  1563.         int send(int, char *, int, int);
  1564.  
  1565.         nbytes = sendto(s, msg, len, flags, to, tolen)
  1566.         D0              D0 A0   D1   D2     A1  D3
  1567.  
  1568.         int send(int, char *, int, int, struct sockaddr *, int);
  1569.  
  1570.    FUNCTION
  1571.         s is a socket created with socket().  send() and sendto() are
  1572.         used  to transmit a message to  another socket. send() may be
  1573.         used  only when the socket  is  in a connected  state,  while
  1574.         sendto() may be used at any time.
  1575.  
  1576.         The address of the target  is given by to with tolen specify-
  1577.         ing its size.  The length of the message is given by len.  If
  1578.         the  message is  too  long  to  pass  atomically  through the
  1579.         underlying protocol, then the error EMSGSIZE is returned, and
  1580.         the message is not transmitted.
  1581.  
  1582.         No indication of failure to deliver is implicit  in a send().
  1583.         Return values of -1 indicate some locally detected errors.
  1584.  
  1585.         If no buffer space is  available at the socket  to  hold  the
  1586.         message  to  be  transmitted,  then  send() normally  blocks,
  1587.         unless the  socket  has been placed in non-blocking I/O mode.
  1588.         The select() call may be used to determine when  it  is  pos-
  1589.         sible to send more data.
  1590.  
  1591.         The flags parameter is formed  by ORing  one  or  more of the
  1592.         following:
  1593.  
  1594.         MSG_OOB           - Send  ``out-of-band''  data  on  sockets
  1595.                             that  support this notion.  The underly-
  1596.                             ing protocol must  also  support  ``out-
  1597.                             of-band''    data.     Currently,   only
  1598.                             SOCK_STREAM  sockets  created   in   the
  1599.                             AF_INET  address  family support out-of-
  1600.                             band data.
  1601.  
  1602.         MSG_DONTROUTE     - The SO_DONTROUTE option is turned on for
  1603.                             the  duration of the operation.  This is
  1604.                             usually used only by diagnostic or rout-
  1605.                             ing programs.
  1606.  
  1607.    RETURN VALUES
  1608.         On success, these functions return the number of bytes sent.
  1609.         On  failure,  they  return  -1 and set errno to indicate the
  1610.         error.
  1611.  
  1612.    ERRORS
  1613.         EBADF             - s is an invalid descriptor.
  1614.  
  1615.         EINTR             - The operation was interrupted by a break 
  1616.                              signal.
  1617.  
  1618.         EINVAL            - len is not the size of a  valid  address
  1619.                             for the specified address family.
  1620.  
  1621.         EMSGSIZE          - The socket requires that message be sent
  1622.                             atomically,  and the size of the message
  1623.                             to be sent made this impossible.
  1624.  
  1625.         ENOBUFS           - The system was  unable  to  allocate  an
  1626.                             internal   buffer.   The  operation  may
  1627.                             succeed when buffers become available.
  1628.  
  1629.         ENOBUFS           - The output queue for a network interface
  1630.                             was full.  This generally indicates that
  1631.                             the interface has stopped  sending,  but
  1632.                             may be caused by transient congestion.
  1633.  
  1634.         EWOULDBLOCK       - The socket is  marked  non-blocking  and
  1635.                             the requested operation would block.
  1636.  
  1637.    SEE ALSO
  1638.         connect(), getsockopt(), recv(), select(), socket()
  1639. bsdsocket.library/sendto                             bsdsocket.library/sendto
  1640.  
  1641.    SEE ALSO
  1642.         send()
  1643. bsdsocket.library/SetErrnoPtr                   bsdsocket.library/SetErrnoPtr
  1644.  
  1645.    NAME
  1646.         SetErrnoPtr - set new place where the error value will be written
  1647.  
  1648.    SYNOPSIS
  1649.         SetErrnoPtr(ptr, size)
  1650.                     A0   D0
  1651.  
  1652.         VOID SetErrnoPtr(VOID *, UBYTE);
  1653.  
  1654.    FUNCTION
  1655.         This functions allows caller to redirect error variable inside
  1656.         scope of  caller task.   Usually this is  used to make  task's
  1657.         global variable errno as error variable.
  1658.  
  1659.    INPUTS
  1660.         ptr     - pointer to error variable that is to be modified on
  1661.                   every error condition on this library function.
  1662.         size    - size of the error variable.
  1663.  
  1664.    EXAMPLE
  1665.         #include <errno.h>
  1666.  
  1667.         struct Library;
  1668.         struct Library * SocketBase = NULL;
  1669.  
  1670.         int main(void)
  1671.         {
  1672.            ...
  1673.           if ((SocketBase = OpenLibrary("bsdsocket.library", 2))
  1674.               != NULL) {
  1675.             SetErrnoPtr(&errno, sizeof(errno));
  1676.            ...
  1677.           }
  1678.         }
  1679.  
  1680.    NOTES
  1681.         Be sure that this new error variable exists until library base
  1682.         is finally closed or SetErrnoPtr() is called again for another
  1683.         variable.
  1684.  
  1685.    SEE ALSO
  1686.         Errno()
  1687.  
  1688. bsdsocket.library/SetSocketSignals         bsdsocket.library/SetSocketSignals
  1689.  
  1690.    NAME
  1691.         SetSocketSignals - inform AmiTCP/IP of INTR, IO and URG signals
  1692.  
  1693.    SYNOPSIS
  1694.         SetSocketSignals(sigintrmask, sigiomask, sigurgmask)
  1695.                          D0           D1         D2
  1696.  
  1697.         VOID SetSocketSignals(ULONG, ULONG, ULONG);
  1698.  
  1699.    FUNCTION
  1700.         SetSocketSignals() tells  the  AmiTCP/IP which signal  masks
  1701.         corresponds UNIX SIGINT, SIGIO and SIGURG signals to be used
  1702.         in   this implementation.  The  sigintrmask  mask is used to
  1703.         determine which  Amiga  signals interrupt  blocking  library
  1704.         calls.
  1705.  
  1706.         The sigiomask  is sent  when  asynchronous  notification  of
  1707.         socket   events   is  done,  the sigurgmask    is  sent when
  1708.         out-of-band   data  arrives, respectively.   The signals are
  1709.         sent only  to  the owning task  of   particular socket.  The
  1710.         socket  has got no owner   by default; the  owner  is set by
  1711.         FIOSETOWN (SIOCSPGRP) ioctl call.
  1712.  
  1713.         Note that the supplied  values write over  old ones. If this
  1714.         function is used and CTRL-C is still wanted to interrupt the
  1715.         calls (the default behaviour),  the value BREAKF_CTRL_C must
  1716.         be explicitly given.
  1717.  
  1718.    NOTES
  1719.         The function SetSocketSignals() is obsoleted by the function
  1720.         SocketBaseTags().
  1721.  
  1722.    SEE ALSO
  1723.         IoctlSocket(), recv(), send(), select(), WaitSelect()
  1724.  
  1725. bsdsocket.library/inet_lnaof                     bsdsocket.library/inet_lnaof
  1726.  
  1727.    SEE ALSO
  1728.        inet_addr()
  1729.  
  1730. bsdsocket.library/inet_makeaddr               bsdsocket.library/inet_makeaddr
  1731.  
  1732.    SEE ALSO
  1733.        inet_addr()
  1734.  
  1735. bsdsocket.library/inet_netof                     bsdsocket.library/inet_netof
  1736.  
  1737.    SEE ALSO
  1738.        inet_addr()
  1739.  
  1740. bsdsocket.library/inet_ntoa                       bsdsocket.library/inet_ntoa
  1741.  
  1742.    SEE ALSO
  1743.        inet_addr()
  1744.  
  1745. bsdsocket.library/setsockopt                     bsdsocket.library/setsockopt
  1746.  
  1747.    SEE ALSO
  1748.         getsockopt()
  1749. bsdsocket.library/shutdown                         bsdsocket.library/shutdown
  1750.  
  1751.    NAME
  1752.         shutdown - shut down part of a full-duplex connection
  1753.  
  1754.    SYNOPSIS
  1755.         success = shutdown(s, how)
  1756.         D0                 D0 D1
  1757.  
  1758.         long shutdown(long, long);
  1759.  
  1760.    DESCRIPTION
  1761.         The shutdown() call causes all or part of a full-duplex con-
  1762.         nection on the socket associated with s to be shut down.  If
  1763.         how is 0, then further receives will be disallowed.  If  how
  1764.         is  1,  then further sends will be disallowed.  If how is 2,
  1765.         then further sends and receives will be disallowed.
  1766.  
  1767.    RETURN VALUES
  1768.          0 - on success.
  1769.  
  1770.         -1 - on failure and sets errno to indicate the error.
  1771.  
  1772.    ERRORS
  1773.         EBADF        - s is not a valid descriptor.
  1774.  
  1775.         ENOTCONN     - The specified socket is not connected.
  1776.  
  1777.    SEE ALSO
  1778.         connect(), socket()
  1779.  
  1780.    BUGS
  1781.         The how values should be defined constants.
  1782. bsdsocket.library/socket                             bsdsocket.library/socket
  1783.  
  1784.    NAME
  1785.         socket - create an endpoint for communication
  1786.  
  1787.    SYNOPSIS
  1788.         #include <sys/types.h>
  1789.         #include <sys/socket.h>
  1790.  
  1791.         s = socket(domain, type, protocol)
  1792.         D0          D0     D1    D2
  1793.  
  1794.         long socket(long, long, long);
  1795.  
  1796.    FUNCTION
  1797.         socket() creates an endpoint for communication and returns a
  1798.         descriptor.
  1799.  
  1800.         The  domain  parameter  specifies  a  communications  domain
  1801.         within which communication will take place; this selects the
  1802.         protocol  family  which should be used.  The protocol family
  1803.         generally  is  the  same  as  the  address  family  for  the
  1804.         addresses supplied in later operations on the socket.  These
  1805.         families  are defined  in the  include file  <sys/socket.h>.
  1806.         The currently understood formats are
  1807.  
  1808.                 PF_INET - (ARPA Internet protocols)
  1809.  
  1810.         The socket has the indicated type, which specifies the
  1811.         semantics of communication.  Currently defined types are:
  1812.  
  1813.                 SOCK_STREAM
  1814.                 SOCK_DGRAM
  1815.                 SOCK_RAW
  1816.  
  1817.         A  SOCK_STREAM type  provides  sequenced,  reliable, two-way
  1818.         connection  based   byte  streams.    An   out-of-band  data
  1819.         transmission  mechanism  may  be  supported.   A  SOCK_DGRAM
  1820.         socket supports datagrams  (connectionless, unreliable  mes-
  1821.         sages  of  a  fixed   (typically   small)  maximum  length).
  1822.         SOCK_RAW   sockets   provide  access  to   internal  network
  1823.         interfaces.
  1824.  
  1825.         The protocol specifies a particular protocol to be used with
  1826.         the socket.  Normally  only a single protocol exists to sup-
  1827.         port a particular socket type  within a given  protocol fam-
  1828.         ily.  However, it is possible that many protocols may exist,
  1829.         in which case a  particular protocol  must be  specified  in
  1830.         this manner.  The  protocol number to use  is  particular to
  1831.         the "communication domain" in which communication is to take
  1832.         place.
  1833.  
  1834.         Sockets of type SOCK_STREAM  are  full-duplex byte  streams,
  1835.         similar to pipes.   A  stream socket must be in  a connected
  1836.         state before any data may be sent or received on it.  A con-
  1837.         nection  to another socket is created with a connect() call.
  1838.         Once  connected, data  may be  transferred using send()  and
  1839.         recv()  or their variant calls.   When  a  session  has been
  1840.         completed a CloseSocket()  may  be  performed.   Out-of-band
  1841.         data may also  be transmitted  as  described  in  send() and
  1842.         received as described in recv().
  1843.  
  1844.         The communications protocols used to implement a SOCK_STREAM
  1845.         insure that data is  not lost or  duplicated.  If a piece of
  1846.         data for  which the peer protocol has buffer space cannot be
  1847.         successfully transmitted within a reasonable length of time,
  1848.         then the  connection  is  considered broken  and  calls will
  1849.         indicate an error with -1 returns and with ETIMEDOUT  as the
  1850.         specific error code (see Errno()).  The protocols optionally
  1851.         keep sockets "warm" by  forcing transmissions roughly  every
  1852.         minute in the absence of other activity.
  1853.  
  1854.         SOCK_DGRAM  and SOCK_RAW sockets allow sending of  datagrams
  1855.         to  correspondents  named in send()  calls.   Datagrams  are
  1856.         generally  received  with  recv(), which  returns  the  next
  1857.         datagram with its return address.
  1858.  
  1859.         The operation of  sockets  is  controlled  by  socket  level
  1860.         options.   These  options  are defined in the file socket.h.
  1861.         getsockopt() and  setsockopt()  are  used  to  get  and  set
  1862.         options, respectively.
  1863.  
  1864.    RETURN VALUES
  1865.         socket() returns a non-negative descriptor on  success.   On
  1866.         failure, it returns -1 and sets errno to indicate the error.
  1867.  
  1868.    ERRORS
  1869.         EACCES          - Permission to create  a  socket  of  the
  1870.                           specified   type   and/or   protocol  is
  1871.                           denied.
  1872.  
  1873.         EMFILE          - The per-process descriptor table is
  1874.                           full.
  1875.  
  1876.         ENOBUFS         - Insufficient buffer space is available.
  1877.                           The socket cannot be created until suf-
  1878.                           ficient resources are freed.
  1879.  
  1880.         EPROTONOSUPPORT - The protocol type or the specified  pro-
  1881.                           tocol is not supported within this
  1882.                           domain.
  1883.  
  1884.         EPROTOTYPE      - The protocol is the wrong type for the
  1885.                           socket.
  1886.  
  1887.    SEE ALSO
  1888.         accept(), bind(), CloseSocket(), connect(), getsockname(),
  1889.         getsockopt(), IoctlSocket(), listen(), recv(), select(), 
  1890.         send(), shutdown(), WaitSelect()
  1891. bsdsocket.library/SocketBaseTagList       bsdsocket.library/SocketBaseTagList
  1892.  
  1893.    NAME
  1894.         SocketBaseTagList - Set/Get SocketBase attributes.
  1895.  
  1896.    SYNOPSIS
  1897.         #include <amitcp/socketbasetags.h>
  1898.  
  1899.         ULONG SocketBaseTagList(struct TagItem *);
  1900.  
  1901.         error = SocketBaseTagList(taglist)
  1902.         D0                        A0
  1903.  
  1904.         error = SocketBaseTags(ULONG tag, ...);
  1905.  
  1906.    FUNCTION
  1907.        Set or get a list of (mostly) SocketBase instance dependent attributes
  1908.        from the AmiTCP.
  1909.  
  1910.    INPUTS
  1911.        These functions expect as their argument a standard tag list, one or
  1912.        several array of struct TagItem as defined in the header file
  1913.        <utility/tagitem.h>. The structure contains two fields: ti_Tag and
  1914.        ti_Data.  The ti_Tag field contains tag code, which determines what
  1915.        the SocketBaseTagList() should do with its argument, the ti_Data
  1916.        field.
  1917.  
  1918.        The include file <amitcp/socketbasetags.h> defines macros for base tag
  1919.        code values.  Base tag code macros begin with `SBTC_' (as Socket Base
  1920.        Tag Code).  The base tag value defines what data item the tag item
  1921.        refers.
  1922.  
  1923.        The tag code contains other information besides the referred data
  1924.        item.  It controls, whether the SocketBaseTagList() should set or get
  1925.        the appropriate parameter, and whether the argument of the tag in
  1926.        question is passed by value or by reference.  
  1927.  
  1928.        The include file <amitcp/socketbasetags.h> defines the following
  1929.        macros, which are used to construct the ti_Tag values from the base
  1930.        tag codes:
  1931.  
  1932.             SBTM_GETREF(code) - get by reference
  1933.             SBTM_GETVAL(code) - get by value
  1934.             SBTM_SETREF(code) - set by reference
  1935.             SBTM_SETVAL(code) - set by value
  1936.  
  1937.        If the actual data is stored directly into the ti_Data field, you
  1938.        should use the 'by value' macros, SBTM_GETVAL() or SBTM_SETVAL().
  1939.        However, if the ti_Data field contains a pointer to actual data, you
  1940.        should use the 'by reference' macros, SBTM_GETREF() or SBTM_SETREF().
  1941.        In either case the actual data should always be a LONG aligned to even
  1942.        address.
  1943.  
  1944.        According the used tag naming scheme a tag which has "PTR" suffix
  1945.        takes an pointer as its argument.  Don't mix the pointer arguments
  1946.        with 'by reference' argument passing.  It is possible to pass a
  1947.        pointer by reference (in which case the ti_Data is a pointer to the
  1948.        actual pointer).
  1949.  
  1950.        The list of all defined base tag codes is as follows:
  1951.  
  1952.             SBTC_BREAKMASK       Tag data contains the INTR signal mask.  If
  1953.                                  the calling task receives a signal in the
  1954.                                  INTR mask, the AmiTCP interrupts current
  1955.                                  function calls and returns with the error
  1956.                                  code EINTR.  The INTR mask defaults to the
  1957.                                  CTRL-C signal (SIGBREAKF_C, bit 12).
  1958.  
  1959.             SBTC_DTABLESIZE      Socket Descriptor Table size. This
  1960.                                  defaults to 64.
  1961.  
  1962.             SBTC_ERRNO           The errno value. The values are defined in
  1963.                                  <sys/errno.h>.
  1964.  
  1965.             SBTC_ERRNOBYTEPTR
  1966.             SBTC_ERRNOWORDPTR
  1967.             SBTC_ERRNOLONGPTR
  1968.             SBTC_ERRNOPTR(size)  Set (only) the pointer to the errno
  1969.                                  variable defined by the program.  AmiTCP
  1970.                                  defines a value for this by default, but
  1971.                                  the application must set the pointer (and
  1972.                                  the size of the errno) with one of these
  1973.                                  tags, if it wishes to access the errno
  1974.                                  variable directly.
  1975.  
  1976.                                  The SBTC_ERRNOPTR(size) is a macro, which
  1977.                                  expands to one of the other (BYTE, WORD or
  1978.                                  LONG) tag codes, meaning that only 1, 2
  1979.                                  and 4 are legal size values.
  1980.  
  1981.                                  The netlib autoinit.c sets the errno
  1982.                                  pointer for the application, if the
  1983.                                  application is linked with it.
  1984.  
  1985.             SBTC_ERRNOSTRPTR     Returns an error string pointer describing
  1986.                                  the errno value given on input. You can not
  1987.                                  set the error message, only get is allowed.
  1988.  
  1989.                                  On call the ti_Data must contain the error
  1990.                                  code number.  On return the ti_Data is
  1991.                                  assigned to the string pointer.  (*ti_Data,
  1992.                                  if passed by reference).  See the file
  1993.                                  <sys/errno.h> for symbolic definitions for
  1994.                                  the errno codes.
  1995.  
  1996.             SBTC_FDCALLBACK      A callback function pointer for coordination
  1997.                                  of file descriptor usage between AmiTCP and
  1998.                                  link-library.  By default no callback is
  1999.                                  called and the value of this pointer is
  2000.                                  NULL.  The prototype for the callback
  2001.                                  function is:
  2002.  
  2003.                                  int error = fdCallback(int fd, int action);
  2004.                                      D0                     D0      D1
  2005.  
  2006.                                  where
  2007.  
  2008.                                  error -  0 for success or one of the error
  2009.                                           codes in <sys/errno.h> in case of
  2010.                                           error. The AmiTCP API function
  2011.                                           that calls the callback usually
  2012.                                           returns the 'error' back to the
  2013.                                           caller without any further
  2014.                                           modification.
  2015.  
  2016.                                  fd -     file descriptor number to take
  2017.                                           'action' on.
  2018.  
  2019.                                  action - one of the following actions
  2020.                                           (defined in
  2021.                                           <amitcp/socketbasetags.h>):
  2022.  
  2023.                                           FDCB_FREE -  mark the 'fd' as
  2024.                                                        unused on the link
  2025.                                                        library structure. If
  2026.                                                        'fd' represents a
  2027.                                                        file handled by the
  2028.                                                        link library, the
  2029.                                                        error (ENOTSOCK)
  2030.                                                        should be returned.
  2031.  
  2032.                                           FDCB_ALLOC - mark the 'fd'
  2033.                                                        allocated as a
  2034.                                                        socket.
  2035.  
  2036.                                           FDCB_CHECK - check if the 'fd' is
  2037.                                                        free. If an error is
  2038.                                                        returned, the 'fd' is
  2039.                                                        marked as used in the
  2040.                                                        AmiTCP/IP structures.
  2041.  
  2042.                                  The AmiTCP/IP calls the callback every time
  2043.                                  a socket descriptor is allocated or freed.
  2044.                                  AmiTCP/IP uses the FDCB_CHECK before actual
  2045.                                  allocation to check that it agrees with the
  2046.                                  link library on the next free descriptor
  2047.                                  number.  Thus the link library doesn't need
  2048.                                  to tell the AmiTCP if it creates a new file
  2049.                                  handle in open(), for example.
  2050.  
  2051.                                  See file _chkufb.c on the net.lib sources
  2052.                                  for an example implementation of the
  2053.                                  callback function for the SAS/C.
  2054.  
  2055.             SBTC_HERRNO          The name resolver error code value. Get
  2056.                                  this to find out why the gethostbyname()
  2057.                                  or gethostbyaddr() failed. The values are
  2058.                                  defined in <netdb.h>
  2059.  
  2060.             SBTC_HERRNOSTRPTR    Returns host error string for error number
  2061.                                  in tag data.  Host error is set on
  2062.                                  unsuccesful gethostbyname() and
  2063.                                  gethostbyaddr() calls. See the file
  2064.                                  <netdb.h> for the symbolic definitions for
  2065.                                  the herrno valus.
  2066.  
  2067.                                  Notes for the SBTC_ERRNOSTRPTR apply also
  2068.                                  to this tag code.
  2069.  
  2070.             SBTC_IOERRNOSTRPTR   Returns an error string for standard
  2071.                                  AmigaOS I/O error number as defined in the
  2072.                                  header file <exec/errors.h>.  Note that the
  2073.                                  error number taken by this tag code is
  2074.                                  positive, so the error codes must be
  2075.                                  negated (to be positive).  The positive
  2076.                                  error codes depend on the particular IO
  2077.                                  device, the standard Sana-II error codes
  2078.                                  can be retrieved by the tag code
  2079.                                  SBTC_S2ERRNOSTRPTR.
  2080.  
  2081.                                  Notes for the SBTC_ERRNOSTRPTR apply also
  2082.                                  to this tag code.
  2083.  
  2084.             SBTC_LOGFACILITY     Facility code for the syslog messages as
  2085.                                  defined in the header file <sys/syslog.h>.
  2086.                                  Defaults to LOG_USER.
  2087.  
  2088.             SBTC_LOGMASK         Sets the filter mask of the syslog
  2089.                                  messages.  By default the mask is 0xff,
  2090.                                  meaning that all messages are passed to the
  2091.                                  log system.
  2092.  
  2093.             SBTC_LOGSTAT         Syslog options defined in <sys/syslog.h>.
  2094.  
  2095.             SBTC_LOGTAGPTR       A pointer to a string which is used by
  2096.                                  syslog() to mark individual syslog
  2097.                                  messages. This defaults to NULL, but is
  2098.                                  set to the name of the calling program by
  2099.                                  the autoinit code in netlib:autoinit.c.
  2100.                                  This is for compatibility with pre-3.0
  2101.                                  programs.
  2102.  
  2103.             SBTC_S2ERRNOSTRPTR   Returns an error string for a Sana-II
  2104.                                  specific I/O error code as defined in the
  2105.                                  header file <devices/sana2.h>.
  2106.  
  2107.                                  Notes for the SBTC_ERRNOSTRPTR apply also
  2108.                                  to this tag code.
  2109.  
  2110.             SBTC_S2WERRNOSTRPTR  Returns an error string for a Sana-II Wire
  2111.                                  Error code as defined in the header file
  2112.                                  <devices/sana2.h>.
  2113.  
  2114.                                  Notes for the SBTC_ERRNOSTRPTR apply also
  2115.                                  to this tag code.
  2116.  
  2117.             SBTC_SIGIOMASK       The calling task is sent the signals
  2118.                                  specified by mask in tag data when
  2119.                                  asynhronous I/O is to be notified. The
  2120.                                  default value is zero, ie. no signal is
  2121.                                  sent.
  2122.  
  2123.             SBTC_SIGURGMASK      The calling task is sent the signals
  2124.                                  specified by mask in tag data when urgent
  2125.                                  data for the TCP arrives. The default value
  2126.                                  is zero, ie. no signal is sent.
  2127.  
  2128.    RESULT 
  2129.        Returns 0 on success, and a (positive) index of the failing tag on
  2130.        error.  Note that the value 1 means _first_ TagItem, 2 the second one,
  2131.        and so on.  The return value is NOT a C-language index, which are 0
  2132.        based.
  2133.  
  2134.    EXAMPLES
  2135.        To be written, see net.lib sources for various examples.
  2136.  
  2137.    NOTES
  2138.  
  2139.    BUGS
  2140.        None known.
  2141.  
  2142.    SEE ALSO
  2143.        <netinclude:amitcp/socketbasetags.h>, <include:utility/tagitem.h>
  2144.  
  2145. bsdsocket.library/syslog                             bsdsocket.library/syslog
  2146.  
  2147.    NAME
  2148.        syslog, vsyslog - write message to AmiTCP/IP log.
  2149.  
  2150.    SYNOPSIS
  2151.        #include <syslog.h>
  2152.  
  2153.        vsyslog(level, format, ap)
  2154.                D0     A0      A1
  2155.  
  2156.        void syslog(unsigned long level, char * format, ...); 
  2157.  
  2158.        void vsyslog(unsigned long level, char * format, ap); 
  2159.  
  2160.    FUNCTION
  2161.        Writes the message given as format string and arguments
  2162.        (printf-style) both to the log file and to the console.
  2163.        The message is prepended with the name of the calling
  2164.        application, if the name is known by AmiTCP (the standard
  2165.        autoinitiazer module in the net.lib passes the name of the
  2166.        application to AmiTCP).
  2167.  
  2168.        The level is selected from an ordered list:
  2169.  
  2170.            LOG_EMERG           A panic condition.
  2171.  
  2172.            LOG_ALERT           A condition that should be
  2173.                                corrected immediately, such as a 
  2174.                                corrupted system database.
  2175.  
  2176.            LOG_CRIT            Critical conditions, such  as  hard
  2177.                                device errors.
  2178.  
  2179.            LOG_ERR             Errors.
  2180.  
  2181.            LOG_WARNING         Warning messages.
  2182.  
  2183.            LOG_NOTICE          Conditions that are not error  con-
  2184.                                ditions,  but that may require spe-
  2185.                                cial handling.
  2186.  
  2187.            LOG_INFO            Informational messages.
  2188.  
  2189.            LOG_DEBUG           Messages that  contain  information
  2190.                                normally of use only when debugging
  2191.                                a program.
  2192.  
  2193.    INPUTS
  2194.        Level     - indicates the type of the message. The levels
  2195.                    are defined in sys/syslog.h and listed above.
  2196.  
  2197.        format    - This is a printf-style format string.
  2198.  
  2199.        arguments - as in printf().
  2200.  
  2201.        ap        - pointer to an array of arguments.
  2202.  
  2203.    RESULT
  2204.        Returns no value.
  2205.  
  2206.    EXAMPLES
  2207.        To log a message at priority LOG_INFO, it would make the
  2208.        following call to syslog:
  2209.  
  2210.            syslog(LOG_INFO,  "Connection from host %s",
  2211.                   CallingHost);
  2212.  
  2213.    NOTES
  2214.        In contrast to the previous releases of the AmiTCP/IP, the
  2215.        integer arguments are expected to be 32 bits wide, thus
  2216.        eliminating the need to specify the 'l' size modifier for the
  2217.        number formatters.
  2218.  
  2219.        This function is callable from interrupts.
  2220.  
  2221.    BUGS
  2222.        Because there is a limited number of internal messages used
  2223.        by the logging system, some log messages may get lost if a
  2224.        high priority task or interrupt handler sends many messages
  2225.        in succession. If this happens, the next log message tells
  2226.        the fact. 
  2227.  
  2228.    SEE ALSO
  2229.        net.lib/syslog for syslog utility functions (openlog(),
  2230.        closelog() and setlogmask()),
  2231.        C-library printf() documentation
  2232.  
  2233. protocols/arp                                                   protocols/arp
  2234.  
  2235.    NAME
  2236.        arp - Address Resolution Protocol
  2237.  
  2238.    CONFIG
  2239.        Any SANA-II device driver using ARP
  2240.  
  2241.    SYNOPSIS
  2242.        #include <sys/socket.h>
  2243.        #include <net/if_arp.h>
  2244.        #include <netinet/in.h>
  2245.  
  2246.        s = socket(AF_INET, SOCK_DGRAM, 0);
  2247.  
  2248.    DESCRIPTION
  2249.        ARP is a protocol used to dynamically map between Internet
  2250.        Protocol (IP) and hardware addresses. It can be used by most
  2251.        the SANA-II network interface drivers. The current
  2252.        implementation supports only Internet Protocol (and is tested
  2253.        only with Ethernet).  However, ARP is not limited to only that
  2254.        combination.
  2255.  
  2256.        ARP caches IP-to-hardware address mappings. When an interface
  2257.        requests a mapping for an address not in the cache, ARP queues
  2258.        the message which requires the mapping and broadcasts a
  2259.        message on the associated network requesting the address
  2260.        mapping. If a response is provided, the new mapping is cached
  2261.        and any pending message is transmitted. ARP will queue at most
  2262.        one packet while waiting for a mapping request to be responded
  2263.        to; only the most recently transmitted packet is kept.
  2264.  
  2265.        The address mapping caches are separate for each interface. The
  2266.        amount of mappings in the cache may be specified with an
  2267.        IoctlSocket() request. 
  2268.  
  2269.        To facilitate communications with systems which do not use ARP,
  2270.        IoctlSocket() requests are provided to enter and delete entries
  2271.        in the IP-to-Ethernet tables.
  2272.  
  2273.    USAGE
  2274.        #include <sys/ioctl.h>
  2275.        #include <sys/socket.h>
  2276.        #include <net/if.h>
  2277.        #include <net/if_arp.h>
  2278.  
  2279.        struct arpreq arpreq;
  2280.  
  2281.        IoctlSocket(s, SIOCSARP, (caddr_t)&arpreq);
  2282.        IoctlSocket(s, SIOCGARP, (caddr_t)&arpreq);
  2283.        IoctlSocket(s, SIOCDARP, (caddr_t)&arpreq);
  2284.  
  2285.        These three IoctlSocket()s take the same structure as an argument.
  2286.        SIOCSARP sets an ARP entry, SIOCGARP gets an ARP entry, and SIOCDARP
  2287.        deletes an ARP entry. These IoctlSocket() requests may be applied to
  2288.        any socket descriptor (s). The arpreq structure contains:
  2289.  
  2290.        /* Maximum number of octets in protocol/hw address */
  2291.        #define MAXADDRARP  16 
  2292.  
  2293.        /*
  2294.         * ARP ioctl request. 
  2295.         */
  2296.        struct arpreq {
  2297.                struct  sockaddr arp_pa;  /* protocol address */
  2298.                struct  {                 /* hardware address */
  2299.                  u_char sa_len;         /* actual length + 2 */
  2300.                  u_char sa_family;             
  2301.                  char   sa_data[MAXADDRARP];           
  2302.                }  arp_ha;              
  2303.                int     arp_flags;                   /* flags */
  2304.        };
  2305.  
  2306.        /*  arp_flags and at_flags field values */
  2307.        #define ATF_INUSE       0x01          /* entry in use */
  2308.        #define ATF_COM         0x02       /* completed entry */
  2309.        #define ATF_PERM        0x04       /* permanent entry */
  2310.        #define ATF_PUBL        0x08         /* publish entry */
  2311.  
  2312.  
  2313.        The interface whose ARP table is manipulated is specified by
  2314.        arp_pa sockaddr. The address family for the arp_pa sockaddr
  2315.        must be AF_INET; for the arp_ha sockaddr it must be AF_UNSPEC.
  2316.        The length of arp_ha must match the length of used hardware
  2317.        address. Maximum length for the hardware address is MAXADDRARP
  2318.        bytes. The only flag bits which may be written are ATF_PERM
  2319.        and ATF_PUBL. ATF_PERM makes the entry permanent if the
  2320.        IoctlSocket() call succeeds. ATF_PUBL specifies that the ARP
  2321.        code should respond to ARP requests for the indicated host
  2322.        coming from other machines.  This allows a host to act as an
  2323.        ARP server which may be useful in convincing an ARP-only
  2324.        machine to talk to a non-ARP machine.
  2325.  
  2326.    UNSUPPORTED IN AmiTCP/IP
  2327.  
  2328.    AmiTCP/IP EXTENSIONS
  2329.        There is an extension to the standard BSD4.4 ARP ioctl interface to
  2330.        access the contents of the whole ARP mapping cache. (In the BSD4.4
  2331.        the static ARP table is accessed via the /dev/kmem.) The SIOCGARPT
  2332.        ioctl takes the following arptabreq structure as an argument:
  2333.  
  2334.        /* 
  2335.         * An AmiTCP/IP specific ARP table ioctl request
  2336.         */
  2337.        struct arptabreq {
  2338.                struct arpreq atr_arpreq;  /* To identify the interface */
  2339.                long   atr_size;          /* # of elements in atr_table */
  2340.                long   atr_inuse;               /* # of elements in use */
  2341.                struct arpreq *atr_table;
  2342.        };
  2343.  
  2344.        The atr_arpreq specifies the used interface. The hardware address
  2345.        for the interface is returned in the arp_ha field of atr_arpreq
  2346.        structure.
  2347.        
  2348.        The SIOCGARPT ioctl reads at most atr_size entries from the cache
  2349.        into the user supplied buffer atr_table, if it is not NULL. Actual
  2350.        amount of returned entries is returned in atr_size. The current
  2351.        amount of cached mappings is returned in the atr_inuse.
  2352.        
  2353.        The SIOCGARPT ioctl has following usage:
  2354.  
  2355.        struct arpreq cache[N];
  2356.        struct arptabreq arptab = { N, 0, cache };
  2357.  
  2358.        IoctlSocket(s, SIOCGARPT, (caddr_t)&arptabreq);
  2359.  
  2360.    DIAGNOSTICS
  2361.        ARP watches passively for hosts impersonating the local host
  2362.        (that  is,  a  host which responds to an ARP mapping request
  2363.        for the local host's address).
  2364.  
  2365.        "duplicate IP address a.b.c.d!!"
  2366.        "sent from hardware address: %x:%x:...:%x:%x"
  2367.  
  2368.        ARP  has  discovered  another host on the local network
  2369.        which responds to mapping requests for its own Internet
  2370.        address.
  2371.  
  2372.    BUGS
  2373.        The ARP is tested only with Ethernet. Other network hardware may
  2374.        require special ifconfig configuration.
  2375.  
  2376.    SEE ALSO
  2377.        inet, netutil/arp, netutil/ifconfig, <net/if_arp.h>
  2378.  
  2379.        Plummer, Dave, ``An  Ethernet  Address  Resolution  Protocol
  2380.        -or-  Converting Network Protocol Addresses to 48.bit Ether-
  2381.        net Addresses for Transmission on Ethernet  Hardware,''  RFC
  2382.        826,  Network  Information  Center, SRI International, Menlo
  2383.        Park, Calif., November 1982. (Sun 800-1059-10)
  2384.  
  2385. protocols/icmp                                                 protocols/icmp
  2386.  
  2387.    NAME
  2388.        icmp - Internet Control Message Protocol
  2389.    
  2390.    SYNOPSIS
  2391.        #include <sys/socket.h>
  2392.        #include <netinet/in.h>
  2393.    
  2394.        int
  2395.        socket(AF_INET, SOCK_RAW, proto)
  2396.    
  2397.    DESCRIPTION
  2398.        ICMP is the error and control message protocol used by IP and the
  2399.        Internet protocol family.  It may be accessed through a ``raw
  2400.        socket'' for network monitoring and diagnostic functions.  The proto
  2401.        parameter to the socket call to create an ICMP socket is obtained
  2402.        from getprotobyname().  ICMP sockets are connectionless, and are
  2403.        normally used with the sendto() and recvfrom() calls, though the
  2404.        connect() call may also be used to fix the destination for future
  2405.        packets (in which case the recv() and send() socket library calls
  2406.        may be used).
  2407.  
  2408.        Outgoing packets automatically have an IP header prepended to them
  2409.        (based on the destination address).  Incoming packets are received
  2410.        with the IP header and options intact.
  2411.    
  2412.    DIAGNOSTICS
  2413.        A socket operation may fail with one of the following errors
  2414.        returned:
  2415.    
  2416.        [EISCONN]        when trying to establish a connection on a socket
  2417.                         which already has one, or when trying to send a
  2418.                         datagram with the destination address specified and
  2419.                         the socket is already connected;
  2420.    
  2421.        [ENOTCONN]       when trying to send a datagram, but no destination
  2422.                         address is specified, and the socket hasn't been
  2423.                         connected;
  2424.    
  2425.        [ENOBUFS]        when the system runs out of memory for an internal
  2426.                         data structure;
  2427.    
  2428.        [EADDRNOTAVAIL]  when an attempt is made to create a socket with a
  2429.                         network address for which no network interface
  2430.                         exists.
  2431.    
  2432.    SEE ALSO
  2433.        bsdsocket.library/send(),  bsdsocket.library/recv(), inet,  ip
  2434.    
  2435.    HISTORY
  2436.        The icmp protocol is originally from 4.3BSD.
  2437.  
  2438. protocols/if                                                     protocols/if
  2439.  
  2440.    NAME
  2441.        if - Network Interface to SANA-II devices
  2442.  
  2443.    DESCRIPTION
  2444.        Each network interface in the AmiTCP/IP corresponds to a path
  2445.        through which messages may be sent and received.  A network
  2446.        interface usually has a SANA-II device driver associated with it,
  2447.        though the loopback interface, "lo", do not. The network interface
  2448.        in the AmiTCP/IP (sana_softc) is superset of the BSD Unix network
  2449.        interface.
  2450.  
  2451.        When the network interface is first time referenced, AmiTCP/IP tries
  2452.        to open the corresponding SANA-II device driver. If successful, a
  2453.        software interface to the SANA-II device is created. The "network/"
  2454.        prefix is added to the SANA-II device name, if needed. Once the
  2455.        interface has acquired its address, it is expected to install a
  2456.        routing table entry so that messages can be routed through it.
  2457.  
  2458.        The SANA-II interfaces must be configured before they will allow
  2459.        traffic to flow through them. It is done after the interface is
  2460.        assigned a protocol address with a SIOCSIFADDR ioctl. Some
  2461.        interfaces may use the protocol address or a part of it as their
  2462.        hardware address. On interfaces where the network-link layer address
  2463.        mapping is static, only the network number is taken from the ioctl;
  2464.        the remainder is found in a hardware specific manner. On interfaces
  2465.        which provide dynamic network-link layer address mapping facilities
  2466.        (for example, Ethernets or Arcnets using ARP), the entire address
  2467.        specified in the ioctl is used.
  2468.  
  2469.        The following ioctl calls may be used to manipulate network
  2470.        interfaces. Unless specified otherwise, the request takes an ifreq
  2471.        structure as its parameter. This structure has the form
  2472.  
  2473.        struct ifreq {
  2474.          char ifr_name[IFNAMSIZ]; /* interface name (eg. "slip.device/0")*/
  2475.          union {
  2476.            struct sockaddr ifru_addr;
  2477.            struct sockaddr ifru_dstaddr;
  2478.            short           ifru_flags;
  2479.          } ifr_ifru;
  2480.        #define ifr_addr    ifr_ifru.ifru_addr                 /* address */
  2481.        #define ifr_dstaddr ifr_ifru.ifru_dstaddr   /* end of p-to-p link */
  2482.        #define ifr_flags   ifr_ifru.ifru_flags                  /* flags */
  2483.        };
  2484.  
  2485.        SIOCSIFADDR      Set interface address. Following the address
  2486.                         assignment, the ``initialization'' routine for
  2487.                         the interface is called.
  2488.  
  2489.        SIOCGIFADDR      Get interface address.
  2490.  
  2491.        SIOCSIFDSTADDR   Set point to point address for interface.
  2492.  
  2493.        SIOCGIFDSTADDR   Get point to point address for interface.
  2494.  
  2495.        SIOCSIFFLAGS     Set interface flags field. If the interface is
  2496.                         marked down, any processes currently routing
  2497.                         packets through the interface are notified.
  2498.  
  2499.        SIOCGIFFLAGS     Get interface flags.
  2500.  
  2501.        SIOCGIFCONF      Get interface configuration list. This request
  2502.                         takes an ifconf structure (see below) as a
  2503.                         value-result parameter. The ifc_len field should be
  2504.                         initially set to the size of the buffer pointed to
  2505.                         by ifc_buf. On return it will contain the length,
  2506.                         in bytes, of the configuration list.
  2507.  
  2508.        /*
  2509.         * Structure used in SIOCGIFCONF request.
  2510.         * Used to retrieve interface configuration
  2511.         * for machine (useful for programs which
  2512.         * must know all networks accessible).
  2513.         */
  2514.        struct ifconf {
  2515.          int  ifc_len;                      /* size of associated buffer */
  2516.          union {
  2517.            caddr_t       ifcu_buf;
  2518.            struct ifreq *ifcu_req;
  2519.          } ifc_ifcu;
  2520.        #define ifc_buf ifc_ifcu.ifcu_buf               /* buffer address */
  2521.        #define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
  2522.        };
  2523.  
  2524.  
  2525.    UNSUPPORTED IN AmiTCP/IP
  2526.        These standard BSD ioctl codes are not currently supported:
  2527.  
  2528.        SIOCADDMULTI     Enable a multicast address for the interface. 
  2529.  
  2530.        SIOCDELMULTI     Disable a previously set multicast address.
  2531.  
  2532.        SIOCSPROMISC     Toggle promiscuous mode.
  2533.  
  2534.    AmiTCP/IP EXTENSIONS
  2535.        The following ioctls are used to configure protocol and hardware
  2536.        specific properties of a sana_softc interface. They are used in the
  2537.        AmiTCP/IP only.
  2538.  
  2539.        SIOCSSANATAGS    Set SANA-II specific properties with a tag list.
  2540.  
  2541.        SIOCGSANATAGS    Get SANA-II specific properties into a
  2542.                         wiretype_parameters structure and a user tag list.
  2543.  
  2544.        struct wiretype_parameters
  2545.        {
  2546.          ULONG  wiretype;               /* the wiretype of the interface */
  2547.          WORD   flags;                                      /* iff_flags */
  2548.          struct TagItem *tags;                 /* tag list user provides */
  2549.        };
  2550.        
  2551.    SEE ALSO
  2552.        arp, lo, netutil/arp, netutil/ifconfig, <sys/ioctl.h>, <net/if.h>, 
  2553.        <net/sana2tags.h>
  2554.  
  2555. protocols/inet                                                 protocols/inet
  2556.  
  2557.    NAME
  2558.        inet - Internet protocol family
  2559.    
  2560.    SYNOPSIS
  2561.        #include <sys/types.h>
  2562.        #include <netinet/in.h>
  2563.    
  2564.    DESCRIPTION
  2565.        The Internet protocol family implements a collection of protocols
  2566.        which are centered around the Internet Protocol (IP) and which share
  2567.        a common address format.  The Internet family provides protocol
  2568.        support for the SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW socket types.
  2569.    
  2570.    PROTOCOLS
  2571.        The Internet protocol family is comprised of the Internet Protocol
  2572.        (IP), the Address Resolution Protocol (ARP), the Internet Control
  2573.        Message Protocol (ICMP), the Transmission Control Protocol (TCP),
  2574.        and the User Datagram Protocol (UDP).
  2575.    
  2576.        TCP is used to support the SOCK_STREAM abstraction while UDP is used
  2577.        to support the SOCK_DGRAM abstraction; (SEE ALSO tcp, SEE ALSO udp).
  2578.        A raw interface to IP is available by creating an Internet socket of
  2579.        type SOCK_RAW; (SEE ALSO ip).  ICMP is used by the kernel to handle
  2580.        and report errors in protocol processing.  It is also accessible to
  2581.        user programs; (SEE ALSO icmp).  ARP is used to translate 32-bit IP
  2582.        addresses into varying length hardware addresses; (SEE ALSO arp).
  2583.    
  2584.        The 32-bit IP address is divided into network number and host number
  2585.        parts.  It is frequency-encoded; the most significant bit is zero in
  2586.        Class A addresses, in which the high-order 8 bits are the network
  2587.        number.  Class B addresses have their high order two bits set to 10
  2588.        and use the highorder 16 bits as the network number field.  Class C
  2589.        addresses have a 24-bit network number part of which the high order
  2590.        three bits are 110.  Sites with a cluster of local networks may
  2591.        chose to use a single network number for the cluster; this is done
  2592.        by using subnet addressing.  The local (host) portion of the address
  2593.        is further subdivided into subnet number and host number parts.
  2594.        Within a subnet, each subnet appears to be an individual network;
  2595.        externally, the entire cluster appears to be a single, uniform
  2596.        network requiring only a single routing entry.  Subnet addressing is
  2597.        enabled and examined by the following ioctl commands on a datagram
  2598.        socket in the Internet domain; they have the same form as the
  2599.        SIOCIFADDR (SEE ALSO if) command.
  2600.    
  2601.        SIOCSIFNETMASK      Set interface network mask.  The network mask
  2602.                            defines the network part of the address; if it
  2603.                            contains more of the address than the address
  2604.                            type would indicate, then subnets are in use.
  2605.    
  2606.        SIOCGIFNETMASK      Get interface network mask.
  2607.    
  2608.    ADDRESSING
  2609.        IP addresses are four byte quantities, stored in network byte order
  2610.        (the native Amiga byte order)
  2611.    
  2612.        Sockets in the Internet protocol family  use  the  following
  2613.        addressing structure:
  2614.             struct sockaddr_in {
  2615.                  short     sin_family;
  2616.                  u_short   sin_port;
  2617.                  struct    in_addr sin_addr;
  2618.                  char sin_zero[8];
  2619.             };
  2620.    
  2621.        Functions in bsdsocket.library are provided to manipulate structures
  2622.        of this form.
  2623.    
  2624.        The sin_addr field of the sockaddr_in structure specifies a local or
  2625.        remote IP address.  Each network interface has its own unique IP
  2626.        address.  The special value INADDR_ANY may be used in this field to
  2627.        effect "wildcard" matching.  Given in a bind() call, this value
  2628.        leaves the local IP address of the socket unspecified, so that the
  2629.        socket will receive connections or messages directed at any of the
  2630.        valid IP addresses of the system.  This can prove useful when a
  2631.        process neither knows nor cares what the local IP address is or when
  2632.        a process wishes to receive requests using all of its network
  2633.        interfaces.  The sockaddr_in structure given in the bind() call must
  2634.        specify an in_addr value of either IPADDR_ANY or one of the system's
  2635.        valid IP addresses.  Requests to bind any other address will elicit
  2636.        the error EADDRNOTAVAIL. When a connect() call is made for a socket
  2637.        that has a wildcard local address, the system sets the sin_addr
  2638.        field of the socket to the IP address of the network interface that
  2639.        the packets for that connection are routed via.
  2640.    
  2641.        The sin_port field of the sockaddr_in structure specifies a port
  2642.        number used by TCP or UDP. The local port address specified in a
  2643.        bind() call is restricted to be greater than IPPORT_RESERVED
  2644.        (defined in <netinet/in.h>) unless the creating process is running
  2645.        as the super-user, providing a space of protected port numbers.  In
  2646.        addition, the local port address must not be in use by any socket of
  2647.        same address family and type.  Requests to bind sockets to port
  2648.        numbers being used by other sockets return the error EADDRINUSE.  If
  2649.        the local port address is specified as 0, then the system picks a
  2650.        unique port address greater than IPPORT_RESERVED.  A unique local
  2651.        port address is also picked when a socket which is not bound is used
  2652.        in a connect() or send() call.  This allows programs which do not
  2653.        care which local port number is used to set up TCP connections by
  2654.        sim- ply calling socket() and then connect(), and to send UDP
  2655.        datagrams with a socket() call followed by a send() call.
  2656.    
  2657.        Although this implementation restricts sockets to unique local port
  2658.        numbers, TCP allows multiple simultaneous connections involving the
  2659.        same local port number so long as the remote IP addresses or port
  2660.        numbers are different for each connection.  Programs may explicitly
  2661.        override the socket restriction by setting the SO_REUSEADDR socket
  2662.        option with setsockopt (see getsockopt()).
  2663.    
  2664.    SEE ALSO
  2665.        bsdsocket.library/bind(), bsdsocket.library/connect(),
  2666.        bsdsocket.library/getsockopt(), bsdsocket.library/IoctlSocket(),
  2667.        bsdsocket.library/send(), bsdsocket.library/socket(),
  2668.        bsdsocket.library/gethostent(), bsdsocket.library/getnetent(),
  2669.        bsdsocket.library/getprotoent(), bsdsocket.library/getservent(),
  2670.        bsdsocket.library/inet_addr(), arp, icmp, ip, tcp, udp
  2671.    
  2672.        Network Information Center, DDN Protocol Handbook (3 vols.),
  2673.        Network  Information  Center, SRI International, Menlo Park,
  2674.        Calif., 1985.
  2675.        A AmiTCP/IP Interprocess Communication Primer
  2676.    
  2677.    WARNING
  2678.        The Internet protocol support is subject to change as the Internet
  2679.        protocols develop.  Users should not depend on details of the
  2680.        current implementation, but rather the services exported.
  2681.  
  2682. protocols/ip                                                     protocols/ip
  2683.  
  2684.    NAME
  2685.        ip - Internet Protocol
  2686.    
  2687.    SYNOPSIS
  2688.        #include <sys/socket.h>
  2689.        #include <netinet/in.h>
  2690.    
  2691.        int
  2692.        socket(AF_INET, SOCK_RAW, proto)
  2693.    
  2694.    DESCRIPTION
  2695.        IP is the transport layer protocol used by the Internet protocol
  2696.        family.  Options may be set at the IP level when using higher-level
  2697.        protocols that are based on IP (such as TCP and UDP). It may also be
  2698.        accessed through a ``raw socket'' when developing new protocols, or
  2699.        special purpose applica- tions.
  2700.    
  2701.        A single generic option is supported at the IP level, IP_OPTIONS,
  2702.        that may be used to provide IP options to be transmitted in the IP
  2703.        header of each outgoing packet.  Options are set with setsockopt()
  2704.        and examined with getsockopt().  The format of IP options to be sent
  2705.        is that specified by the IP protocol specification, with one
  2706.        exception: the list of addresses for Source Route options must
  2707.        include the first-hop gateway at the beginning of the list of
  2708.        gateways.  The first-hop gateway address will be extracted from the
  2709.        option list and the size adjusted accordingly before use.  IP
  2710.        options may be used with any socket type in the Internet family.
  2711.    
  2712.        Raw IP sockets are connectionless, and are normally used with the
  2713.        sendto and recvfrom calls, though the connect() call may also be
  2714.        used to fix the destination for future packets (in which case the
  2715.        recv() and send() system calls may be used).
  2716.    
  2717.        If proto is 0, the default protocol IPPROTO_RAW is used for outgoing
  2718.        packets, and only incoming packets destined for that protocol are
  2719.        received.  If proto is non-zero, that protocol number will be used
  2720.        on outgoing packets and to filter incoming packets.
  2721.    
  2722.        Outgoing packets automatically have an IP header prepended to them
  2723.        (based on the destination address and the protocol number the socket
  2724.        is created with).  Incoming packets are received with IP header and
  2725.        options intact.
  2726.    
  2727.    DIAGNOSTICS
  2728.        A socket operation may fail with one of the following errors
  2729.        returned:
  2730.    
  2731.        [EISCONN]        when trying to establish a connection on a socket
  2732.                         which already has one, or when trying to send a
  2733.                         datagram with the destination address specified and
  2734.                         the socket is already connected;
  2735.    
  2736.        [ENOTCONN]       when trying to send a datagram, but no destination
  2737.                         address is specified, and the socket hasn't been
  2738.                         connected;
  2739.    
  2740.        [ENOBUFS]        when the system runs out of memory for an internal
  2741.                         data structure;
  2742.    
  2743.        [EADDRNOTAVAIL]  when an attempt is made to create a socket with a
  2744.                         network address for which no network interface
  2745.                         exists.
  2746.    
  2747.        The following errors specific to IP may occur when setting or
  2748.        getting IP options:
  2749.    
  2750.        [EINVAL]         An unknown socket option name was given.
  2751.    
  2752.        [EINVAL]         The IP option field was improperly formed; an
  2753.                         option field was shorter than the minimum value or
  2754.                         longer than the option buffer provided.
  2755.    
  2756.    SEE ALSO
  2757.        bsdsocket.library/getsockopt(), bsdsocket.library/send(),
  2758.        bsdsocket.library/recv(), icmp, inet
  2759.  
  2760.    HISTORY
  2761.        The ip protocol appeared in 4.2BSD.
  2762.  
  2763. protocols/lo                                                     protocols/lo
  2764.  
  2765.    NAME
  2766.        lo - Software Loopback Network Interface
  2767.  
  2768.    SYNOPSIS
  2769.        pseudo-device
  2770.        loop
  2771.  
  2772.    DESCRIPTION
  2773.        The loop interface is a software loopback mechanism which may be
  2774.        used for performance analysis, software testing, and/or local
  2775.        communication.  There is no SANA-II interface associated with lo.
  2776.        As with other network interfaces, the loopback interface must have
  2777.        network addresses assigned for each address family with which it is
  2778.        to be used.  These addresses may be set or changed with the
  2779.        SIOCSIFADDR ioctl. The loopback interface should be the last
  2780.        interface configured, as protocols may use the order of
  2781.        configuration as an indication of priority.  The loopback should
  2782.        never be configured first unless no hardware interfaces exist.
  2783.  
  2784.    DIAGNOSTICS
  2785.        "lo%d: can't handle af%d."
  2786.        The interface was handed a message with ad- dresses formatted in an
  2787.        unsuitable address family; the packet was dropped.
  2788.  
  2789.    SEE ALSO
  2790.        inet, if, netutil/ifconfig
  2791.  
  2792.    BUGS 
  2793.        Older BSD Unix systems enabled the loopback interface
  2794.        automatically, using a nonstandard Internet address (127.1).  Use
  2795.        of that address is now discouraged; a reserved host address for the
  2796.        local network should be used instead.
  2797.  
  2798. protocols/routing                                           protocols/routing
  2799.  
  2800.    NAME
  2801.        routing - system supporting for local network packet routing
  2802.    
  2803.    DESCRIPTION
  2804.        The network facilities provided general packet routing,
  2805.        leaving routing table maintenance to applications processes.
  2806.    
  2807.        A simple set of data structures comprise a ``routing table''
  2808.        used in selecting the appropriate network interface when
  2809.        transmitting packets.  This table contains a single entry for
  2810.        each route to a specific network or host.  A user process, the
  2811.        routing daemon, maintains this data base with the aid of two
  2812.        socket specific ioctl commands, SIOCADDRT and SIOCDELRT.
  2813.        The commands allow the addition and deletion of a single
  2814.        routing table entry, respectively.  Routing table
  2815.        manipulations may only be carried out by super-user.
  2816.    
  2817.        A routing table entry has the following form, as defined  in
  2818.        <net/route.h>:
  2819.             struct rtentry {
  2820.                  u_long    rt_hash;
  2821.                  struct    sockaddr rt_dst;
  2822.                  struct    sockaddr rt_gateway;
  2823.                  short     rt_flags;
  2824.                  short     rt_refcnt;
  2825.                  u_long    rt_use;
  2826.                  struct    ifnet *rt_ifp;
  2827.             };
  2828.        with rt_flags defined from:
  2829.          #define   RTF_UP         0x1              /* route usable */
  2830.          #define   RTF_GATEWAY    0x2  /* destination is a gateway */
  2831.          #define   RTF_HOST  0x4     /* host entry (net otherwise) */
  2832.    
  2833.        Routing table entries come in three flavors: for a specific
  2834.        host, for all hosts on a specific network, for any destination
  2835.        not matched by entries of the first two types (a wildcard
  2836.        route).  When the system is booted, each network interface
  2837.        autoconfigured installs a routing table entry when it wishes
  2838.        to have packets sent through it.  Normally the interface
  2839.        specifies the route through it is a ``direct'' connection to
  2840.        the destination host or network.  If the route is direct, the
  2841.        transport layer of a protocol family usually requests the
  2842.        packet be sent to the same host specified in the packet.
  2843.        Otherwise, the interface may be requested to address the
  2844.        packet to an entity different from the eventual recipient
  2845.        (that is, the packet is forwarded).
  2846.    
  2847.        Routing table entries installed by a user process may not
  2848.        specify the hash, reference count, use, or interface fields;
  2849.        these are filled in by the routing routines.  If a route is in
  2850.        use when it is deleted (rt_refcnt is non-zero), the resources
  2851.        associated with it will not be reclaimed until all references
  2852.        to it are removed.
  2853.    
  2854.        The routing code returns EEXIST if requested to duplicate an
  2855.        existing entry, ESRCH if requested to delete a non-existent
  2856.        entry, or ENOBUFS if insufficient resources were available to
  2857.        install a new route.
  2858.    
  2859.        The rt_use field contains the number of packets sent along the
  2860.        route.  This value is used to select among multiple routes to
  2861.        the same destination.  When multiple routes to the same
  2862.        destination exist, the least used route is selected.
  2863.    
  2864.        A wildcard routing entry is specified with a zero destination
  2865.        address value.  Wildcard routes are used only when the system
  2866.        fails to find a route to the destination host and network.
  2867.        The combination of wildcard routes and routing redirects can
  2868.        provide an economical mechanism for routing traffic.
  2869.    
  2870.    SEE ALSO
  2871.        bsdsocket.library/IoctlSocket(), netutil/route
  2872.    
  2873. protocols/tcp                                                   protocols/tcp
  2874.  
  2875.    NAME
  2876.        tcp - Internet Transmission Control Protocol
  2877.    
  2878.    SYNOPSIS
  2879.        #include <sys/socket.h>
  2880.        #include <netinet/in.h>
  2881.    
  2882.        int
  2883.        socket(AF_INET, SOCK_STREAM, 0)
  2884.    
  2885.    DESCRIPTION
  2886.        The TCP protocol provides reliable, flow-controlled, two-way
  2887.        transmission of data.  It is a byte-stream protocol used to support
  2888.        the SOCK_STREAM abstraction.  TCP uses the standard Internet address
  2889.        format and, in addition, provides a per-host collection of ``port
  2890.        addresses''. Thus, each address is composed of an Internet address
  2891.        specifying the host and network, with a specific TCP port on the
  2892.        host identifying the peer entity.
  2893.    
  2894.        Sockets utilizing the tcp protocol are either ``active'' or
  2895.        ``passive''.  Active sockets initiate connections to passive
  2896.        sockets.  By default TCP sockets are created active; to create a
  2897.        passive socket the listen() bsdsocket.library function call must be
  2898.        used after binding the socket with the bind() bsdsocket.library
  2899.        function call.  Only passive sockets may use the accept() call to
  2900.        accept incoming connections.  Only active sockets may use the
  2901.        connect() call to initiate connections.
  2902.    
  2903.        Passive sockets may ``underspecify'' their location to match
  2904.        incoming connection requests from multiple networks.  This
  2905.        technique, termed ``wildcard addressing'', allows a single server to
  2906.        provide service to clients on multiple networks.  To create a socket
  2907.        which listens on all networks, the Internet address INADDR_ANY must
  2908.        be bound.  The TCP port may still be specified at this time; if the
  2909.        port is not specified the bsdsocket.library function will assign
  2910.        one.  Once a connection has been established the socket's address is
  2911.        fixed by the peer entity's location.  The address assigned the
  2912.        socket is the address associated with the network interface through
  2913.        which packets are being transmitted and received.  Normally this
  2914.        address corresponds to the peer entity's network.
  2915.    
  2916.        TCP supports one socket option which is set with setsockopt() and
  2917.        tested with getsockopt().  Under most circumstances, TCP sends data
  2918.        when it is presented; when outstanding data has not yet been
  2919.        acknowledged, it gathers small amounts of output to be sent in a
  2920.        single packet once an acknowledgement is received.  For a small
  2921.        number of clients, such as X Window System functions that
  2922.        send a stream of mouse events which receive no replies, this
  2923.        packetization may cause significant delays.  Therefore, TCP provides
  2924.        a boolean option, TCP_NODELAY (from <netinet/tcp.h>, to defeat this
  2925.        algorithm.  The option level for the setsockopt call is the protocol
  2926.        number for TCP, available from getprotobyname().
  2927.    
  2928.        Options at the IP transport level may be used with TCP; SEE ALSO ip.
  2929.        Incoming connection requests that are source-routed are noted, and
  2930.        the reverse source route is used in responding.
  2931.    
  2932.    DIAGNOSTICS
  2933.        A socket operation may fail with one of the following errors
  2934.        returned:
  2935.    
  2936.        [EISCONN]        when trying to establish a connection on a socket
  2937.                         which already has one;
  2938.    
  2939.        [ENOBUFS]        when the AmiTCP/IP runs out of memory for an internal
  2940.                         data structure;
  2941.    
  2942.        [ETIMEDOUT]      when a connection was dropped due to excessive
  2943.                         retransmissions;
  2944.    
  2945.        [ECONNRESET]     when the remote peer forces the connection to be
  2946.                         closed;
  2947.    
  2948.        [ECONNREFUSED]   when the remote peer actively refuses connection
  2949.                         establishment (usually because no process is
  2950.                         listening to the port);
  2951.    
  2952.        [EADDRINUSE]     when an attempt is made to create a socket with a
  2953.                         port which has already been allocated;
  2954.    
  2955.        [EADDRNOTAVAIL]  when an attempt is made to create a socket with a
  2956.                         network address for which no network interface
  2957.                         exists.
  2958.    
  2959.    SEE ALSO 
  2960.        bsdsocket.library/getsockopt(), bsdsocket.library/socket(),
  2961.        bsdsocket.library/bind(), bsdsocket.library/listen(),
  2962.        bsdsocket.library/accept(), bsdsocket.library/connect(), inet,
  2963.        ip, <sys/socket.h>, <netinet/tcp.h>, <netinet/in.h>
  2964.    
  2965.    HISTORY
  2966.        The tcp protocol stack appeared in 4.2BSD.
  2967.  
  2968. protocols/udp                                                   protocols/udp
  2969.  
  2970.    NAME
  2971.        udp - Internet User Datagram Protocol
  2972.    
  2973.    SYNOPSIS
  2974.        #include <sys/socket.h>
  2975.        #include <netinet/in.h>
  2976.    
  2977.        int
  2978.        socket(AF_INET, SOCK_DGRAM, 0)
  2979.    
  2980.    DESCRIPTION
  2981.        UDP is a simple, unreliable datagram protocol which is used to
  2982.        support the SOCK_DGRAM abstraction for the Internet protocol family.
  2983.        UDP sockets are connectionless, and are normally used with the
  2984.        sendto() and recvfrom() calls, though the connect() call may also be
  2985.        used to fix the destination for future packets (in which case the
  2986.        recv() and send() function calls may be used).
  2987.    
  2988.        UDP address formats are identical to those used by TCP. In
  2989.        particular UDP provides a port identifier in addition to the normal
  2990.        Internet address format.  Note that the UDP port space is separate
  2991.        from the TCP port space (i.e. a UDP port may not be ``connected'' to
  2992.        a TCP port). In addition broadcast packets may be sent (assuming the
  2993.        underlying network supports this) by using a reserved ``broadcast
  2994.        address''; this address is network interface dependent.
  2995.    
  2996.        Options at the IP transport level may be used with UDP; SEE ALSO ip.
  2997.    
  2998.    DIAGNOSTICS
  2999.        A socket operation may fail with one of the following errors
  3000.        returned:
  3001.    
  3002.        [EISCONN]        when trying to establish a connection on a socket
  3003.                         which already has one, or when trying to send a
  3004.                         datagram with the destination address specified and
  3005.                         the socket is already connected;
  3006.    
  3007.        [ENOTCONN]       when trying to send a datagram, but no destination
  3008.                         address is specified, and the socket hasn't been
  3009.                         connected;
  3010.    
  3011.        [ENOBUFS]        when the system runs out of memory for an
  3012.                         internal data structure;
  3013.    
  3014.        [EADDRINUSE]     when an attempt is made to create a socket with a
  3015.                         port which has already been allocated;
  3016.    
  3017.        [EADDRNOTAVAIL]  when an attempt is made to create a socket with a
  3018.                         network address for which no network interface
  3019.                         exists.
  3020.    
  3021.    SEE ALSO
  3022.        bsdsocket.library/getsockopt(), bsdsocket.library/recv(),
  3023.        bsdsocket.library/send(), bsdsocket.library/socket(), inet, ip
  3024.    
  3025.    HISTORY
  3026.        The udp protocol appeared in 4.2BSD.
  3027.  
  3028.